Skip to content

Commit

Permalink
Merge pull request #2424 from acterglobal/kumar/general-fixes
Browse files Browse the repository at this point in the history
General Fixes
  • Loading branch information
kumarpalsinh25 authored Dec 11, 2024
2 parents fba0384 + c31cc25 commit 7720004
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 85 deletions.
2 changes: 2 additions & 0 deletions .changes/2424-general-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Enhancement] : Create Space and Create Chat now always visible irrespective of space counts
- [Fixes] : Keyboard over-lapping issue while space selection in add boast is now fixed
18 changes: 11 additions & 7 deletions app/lib/common/widgets/spaces/space_selector_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ Future<String?> selectSpaceDrawer({
enableDrag: true,
context: context,
isDismissible: true,
builder: (context) => SelectRoomDrawer(
key: key,
canCheck: canCheck,
currentSpaceId: currentSpaceId,
title: title ?? Text(L10n.of(context).selectSpace),
keyPrefix: 'select-space',
roomType: RoomType.space,
isScrollControlled: true,
builder: (context) => Container(
constraints: BoxConstraints(maxHeight: 700),
child: SelectRoomDrawer(
key: key,
canCheck: canCheck,
currentSpaceId: currentSpaceId,
title: title ?? Text(L10n.of(context).selectSpace),
keyPrefix: 'select-space',
roomType: RoomType.space,
),
),
);
if (selected == null) {
Expand Down
54 changes: 22 additions & 32 deletions app/lib/features/home/widgets/quick_action_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ class QuickActionButtons extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final hasSpaces = ref.watch(hasSpacesProvider);

return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Wrap(
children: hasSpaces
? quickActionWhenHasSpaces(context, ref)
: quickActionWhenNoSpaces(context, ref),
children: quickActions(context, ref),
),
const SizedBox(height: 5),
Row(
Expand Down Expand Up @@ -75,7 +71,7 @@ class QuickActionButtons extends ConsumerWidget {
);
}

List<Widget> quickActionWhenHasSpaces(BuildContext context, WidgetRef ref) {
List<Widget> quickActions(BuildContext context, WidgetRef ref) {
final lang = L10n.of(context);
final canAddPin =
ref.watch(hasSpaceWithPermissionProvider('CanPostPin')).valueOrNull ??
Expand All @@ -90,6 +86,26 @@ class QuickActionButtons extends ConsumerWidget {
ref.watch(hasSpaceWithPermissionProvider('CanPostNews')).valueOrNull ??
false;
return [
ActionButtonWidget(
iconData: Atlas.users,
title: lang.createSpace,
color: Colors.purpleAccent.withAlpha(70),
padding: const EdgeInsets.symmetric(vertical: 6),
onPressed: () {
ref.read(quickActionVisibilityProvider.notifier).state = false;
context.pushNamed(Routes.createSpace.name);
},
),
ActionButtonWidget(
iconData: Atlas.chats,
title: lang.createChat,
color: Colors.green.withAlpha(70),
padding: const EdgeInsets.symmetric(vertical: 6),
onPressed: () {
ref.read(quickActionVisibilityProvider.notifier).state = false;
context.pushNamed(Routes.createChat.name);
},
),
if (canAddPin)
ActionButtonWidget(
iconData: Atlas.pin,
Expand Down Expand Up @@ -136,30 +152,4 @@ class QuickActionButtons extends ConsumerWidget {
),
];
}

List<Widget> quickActionWhenNoSpaces(BuildContext context, WidgetRef ref) {
final lang = L10n.of(context);
return [
ActionButtonWidget(
iconData: Atlas.users,
title: lang.createSpace,
color: Colors.purpleAccent.withAlpha(70),
padding: const EdgeInsets.symmetric(vertical: 6),
onPressed: () {
ref.read(quickActionVisibilityProvider.notifier).state = false;
context.pushNamed(Routes.createSpace.name);
},
),
ActionButtonWidget(
iconData: Atlas.chats,
title: lang.createChat,
color: Colors.green.withAlpha(70),
padding: const EdgeInsets.symmetric(vertical: 6),
onPressed: () {
ref.read(quickActionVisibilityProvider.notifier).state = false;
context.pushNamed(Routes.createChat.name);
},
),
];
}
}
76 changes: 31 additions & 45 deletions app/lib/features/home/widgets/sidebar_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,27 +204,49 @@ class SidebarWidget extends ConsumerWidget {
indent: 18,
endIndent: 18,
),
_quickActionButton(context, ref),
quickActions(context, ref),
if (isBugReportingEnabled) ..._bugReporter(context),
const SizedBox(height: 12),
],
),
);
}

Widget _quickActionButton(BuildContext context, WidgetRef ref) {
final hasSpaces = ref.watch(hasSpacesProvider);
return hasSpaces
? quickActionWhenHasSpaces(context, ref)
: quickActionWhenNoSpaces(context, ref);
}

PopupMenuButton quickActionWhenHasSpaces(
PopupMenuButton quickActions(
BuildContext context,
WidgetRef ref,
) {
final lang = L10n.of(context);
List<PopupMenuEntry> actions = [];

actions.add(
PopupMenuItem(
child: ActionButtonWidget(
iconData: Atlas.users,
color: Colors.purpleAccent.withAlpha(70),
title: lang.createSpace,
onPressed: () {
if (context.canPop()) Navigator.pop(context);
context.pushNamed(Routes.createSpace.name);
},
),
),
);

actions.add(
PopupMenuItem(
child: ActionButtonWidget(
iconData: Atlas.chats,
title: lang.createChat,
color: Colors.green.withAlpha(70),
onPressed: () {
if (context.canPop()) Navigator.pop(context);
context.pushNamed(Routes.createChat.name);
},
),
),
);

final canAddPin =
ref.watch(hasSpaceWithPermissionProvider('CanPostPin')).valueOrNull ??
false;
Expand Down Expand Up @@ -306,42 +328,6 @@ class SidebarWidget extends ConsumerWidget {
);
}

PopupMenuButton quickActionWhenNoSpaces(
BuildContext context,
WidgetRef ref,
) {
final lang = L10n.of(context);
return PopupMenuButton(
icon: const Icon(Atlas.plus_circle),
iconSize: 28,
color: Theme.of(context).colorScheme.surface,
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
child: ActionButtonWidget(
iconData: Atlas.users,
color: Colors.purpleAccent.withAlpha(70),
title: lang.createSpace,
onPressed: () {
if (context.canPop()) Navigator.pop(context);
context.pushNamed(Routes.createSpace.name);
},
),
),
PopupMenuItem(
child: ActionButtonWidget(
iconData: Atlas.chats,
title: lang.createChat,
color: Colors.green.withAlpha(70),
onPressed: () {
if (context.canPop()) Navigator.pop(context);
context.pushNamed(Routes.createChat.name);
},
),
),
],
);
}

List<Widget> _bugReporter(BuildContext context) {
return [
const Divider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BottomNavigationWidget extends ConsumerWidget {
bottomNavNar(ref),
AnimatedContainer(
duration: const Duration(milliseconds: 300),
height: showQuickActions ? 180 : 0,
height: showQuickActions ? 250 : 0,
child: const QuickActionButtons(),
),
],
Expand Down

0 comments on commit 7720004

Please sign in to comment.