Skip to content

Commit

Permalink
feat: add functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sonle-geekyants committed Mar 19, 2024
1 parent 8d6cf16 commit 884dbb0
Show file tree
Hide file tree
Showing 14 changed files with 849 additions and 357 deletions.
4 changes: 4 additions & 0 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:atsign_atmosphere_pro/view_models/desktop_groups_screen_provider
import 'package:atsign_atmosphere_pro/view_models/file_download_checker.dart';
import 'package:atsign_atmosphere_pro/desktop_routes/desktop_routes.dart';
import 'package:atsign_atmosphere_pro/view_models/file_progress_provider.dart';
import 'package:atsign_atmosphere_pro/view_models/groups_provider.dart';
import 'package:atsign_atmosphere_pro/view_models/internet_connectivity_checker.dart';
import 'package:atsign_atmosphere_pro/view_models/my_files_provider.dart';
import 'package:atsign_atmosphere_pro/view_models/side_bar_provider.dart';
Expand Down Expand Up @@ -72,6 +73,9 @@ class _MyAppState extends State<MyApp> {
ChangeNotifierProvider(create: (context) => DesktopAddGroupProvider()),
ChangeNotifierProvider(create: (context) => ContactProvider()),
ChangeNotifierProvider(create: (context) => NotificationService()),
ChangeNotifierProvider(
create: (context) => GroupsProvider(),
),
],
child: MaterialApp(
builder: (BuildContext context, Widget? child) {
Expand Down
12 changes: 6 additions & 6 deletions lib/desktop_screens_new/groups_screen/desktop_groups_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class _DesktopGroupsScreenState extends State<DesktopGroupsScreen> {
snapshot.data!,
key: UniqueKey(),
expandIndex: GroupService().expandIndex ?? 0,
onExpand: (value) {
provider.setSelectedAtGroup(value);
onExpand: (value) async {
await provider.setSelectedAtGroup(value);
provider.setGroupCardState(GroupCardState.expanded);
},
onAdd: () {
Expand All @@ -111,8 +111,8 @@ class _DesktopGroupsScreenState extends State<DesktopGroupsScreen> {
children: [
Expanded(
child: InkWell(
onTap: () {
groupsProvider.setSelectedAtGroup(null);
onTap: () async {
await groupsProvider.setSelectedAtGroup(null);
groupsProvider
.setGroupCardState(GroupCardState.disable);
},
Expand All @@ -135,15 +135,15 @@ class _DesktopGroupsScreenState extends State<DesktopGroupsScreen> {
return DesktopAddGroup(
onDoneTap: (value) async {
if (value) await GroupService().getAllGroupsDetails();
groupsProvider.setSelectedAtGroup(null);
await groupsProvider.setSelectedAtGroup(null);
groupsProvider.setGroupCardState(GroupCardState.disable);
},
);
case GroupCardState.expanded:
return DesktopGroupsDetail(
onBackArrowTap: (value) async {
if (value) await GroupService().getAllGroupsDetails();
groupsProvider.setSelectedAtGroup(null);
await groupsProvider.setSelectedAtGroup(null);
groupsProvider.setGroupCardState(GroupCardState.disable);
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class _DesktopGroupsDetailState extends State<DesktopGroupsDetail> {
titleTextStyle: CustomTextStyles.blackW50020,
leadingIcon: InkWell(
onTap: provider.isEditing
? () {
provider.setIsEditing(false);
? () async {
await provider.setIsEditing(false);
if (provider.isAddingContacts) {
provider.setIsAddingContact();
}
Expand Down Expand Up @@ -155,7 +155,7 @@ class _DesktopGroupsDetailState extends State<DesktopGroupsDetail> {
bgColor: ColorConstants.redAlert,
);
} else {
provider.setSelectedGroupImage(
await provider.setSelectedGroupImage(
await File(details.files.first.path)
.readAsBytes(),
);
Expand Down Expand Up @@ -292,7 +292,7 @@ class _DesktopGroupsDetailState extends State<DesktopGroupsDetail> {
IconButtonWidget(
icon: AppVectors.icEdit,
backgroundColor: ColorConstants.iconButtonColor,
onTap: () => groupProvider.setIsEditing(true),
onTap: () async => await groupProvider.setIsEditing(true),
),
const SizedBox(width: 24),
IconButtonWidget(
Expand Down Expand Up @@ -330,7 +330,7 @@ class _DesktopGroupsDetailState extends State<DesktopGroupsDetail> {
if (!mounted) return;
if (result != null && result) {
Navigator.of(context).pop();
groupProvider.setSelectedAtGroup(null);
await groupProvider.setSelectedAtGroup(null);
groupProvider.setGroupCardState(GroupCardState.disable);
} else {
CustomToast().show(TextConstants().SERVICE_ERROR, context);
Expand Down
58 changes: 29 additions & 29 deletions lib/screens/common_widgets/cover_image_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,39 +70,39 @@ class CoverImagePicker extends StatelessWidget {
right: 12,
left: 12,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: onCancel,
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white54.withOpacity(0.5),
),
child: SvgPicture.asset(
AppVectors.icCancel,
width: 16,
height: 16,
color: Colors.black,
fit: BoxFit.cover,
),
),
),
if (groupImage != null)
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white54.withOpacity(0.5),
),
child: SvgPicture.asset(
AppVectors.icEdit,
width: 16,
height: 16,
fit: BoxFit.cover,
InkWell(
onTap: onCancel,
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white54.withOpacity(0.5),
),
child: SvgPicture.asset(
AppVectors.icCancel,
width: 16,
height: 16,
color: Colors.black,
fit: BoxFit.cover,
),
),
),
Spacer(),
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white54.withOpacity(0.5),
),
child: SvgPicture.asset(
AppVectors.icEdit,
width: 16,
height: 16,
fit: BoxFit.cover,
),
),
],
),
),
Expand Down
8 changes: 7 additions & 1 deletion lib/screens/contact_new_version/contact_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,20 @@ class _ContactScreenState extends State<ContactScreen>
.addPostFrameCallback((_) async {
_groupService.groupViewSink.add(group);
});
await Navigator.push(
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => GroupContactsScreen(
group: group,
),
),
);

if (result ?? false) {
setState(() => isReloading = !isReloading);
await _groupService.fetchGroupsAndContacts();
setState(() => isReloading = !isReloading);
}
},
onTapAddButton: () async {
final result = await showModalBottomSheet<bool?>(
Expand Down
Loading

0 comments on commit 884dbb0

Please sign in to comment.