Skip to content

Commit

Permalink
Merge pull request #2344 from acterglobal/ben-tasks-overall-improvements
Browse files Browse the repository at this point in the history
Tasks overall design improvements
  • Loading branch information
gnunicorn authored Nov 4, 2024
2 parents e51aeb8 + 51e0d62 commit b937d58
Show file tree
Hide file tree
Showing 34 changed files with 1,552 additions and 861 deletions.
1 change: 1 addition & 0 deletions .changes/2434-task-quick-actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Create Tasks right from the quick actions, including to select the target space and list.
22 changes: 22 additions & 0 deletions app/lib/common/actions/select_space.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:acter/common/providers/space_providers.dart';
import 'package:acter/common/widgets/spaces/space_selector_drawer.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

const Key selectSpaceDrawerKey = Key('space-widgets-select-space-drawer');

Future<String?> selectSpace({
required BuildContext context,
required WidgetRef ref,
required String canCheck,
}) async {
final newSelectedSpaceId = await selectSpaceDrawer(
context: context,
currentSpaceId: ref.read(selectedSpaceIdProvider),
canCheck: canCheck,
title: Text(L10n.of(context).selectSpace),
);
ref.read(selectedSpaceIdProvider.notifier).state = newSelectedSpaceId;
return newSelectedSpaceId;
}
10 changes: 5 additions & 5 deletions app/lib/common/widgets/spaces/select_space_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SelectSpaceFormField extends ConsumerWidget {
final String? emptyText;
final String canCheck;
final bool mandatory;
final bool useCompatView;
final bool useCompactView;

const SelectSpaceFormField({
super.key,
Expand All @@ -23,7 +23,7 @@ class SelectSpaceFormField extends ConsumerWidget {
this.emptyText,
this.mandatory = true,
required this.canCheck,
this.useCompatView = false,
this.useCompactView = false,
});

void selectSpace(BuildContext context, WidgetRef ref) async {
Expand Down Expand Up @@ -55,7 +55,7 @@ class SelectSpaceFormField extends ConsumerWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (!useCompatView)
if (!useCompactView)
Text(
title ?? lang.space,
style: Theme.of(context).textTheme.bodyMedium,
Expand Down Expand Up @@ -105,9 +105,9 @@ class SelectSpaceFormField extends ConsumerWidget {
(p0) => SpaceChip(
spaceId: p0.roomId,
onTapOpenSpaceDetail: false,
useCompatView: useCompatView,
useCompactView: useCompactView,
onTapSelectSpace: () {
if (useCompatView) selectSpace(context, ref);
if (useCompactView) selectSpace(context, ref);
},
),
) ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class CommentsSectionWidget extends ConsumerWidget {
);
}

static CommentListSkeletonWidget loading() =>
const CommentListSkeletonWidget();

Widget buildCommentSectionUI(
BuildContext context,
CommentsManager commentManager,
Expand Down
19 changes: 6 additions & 13 deletions app/lib/features/events/pages/create_event_page.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:acter/common/actions/select_space.dart';
import 'package:acter/common/extensions/options.dart';
import 'package:acter/common/providers/space_providers.dart';
import 'package:acter/common/toolkit/buttons/primary_action_button.dart';
import 'package:acter/common/utils/routes.dart';
import 'package:acter/common/utils/utils.dart';
import 'package:acter/common/widgets/html_editor.dart';
import 'package:acter/common/widgets/spaces/select_space_form_field.dart';
import 'package:acter/common/widgets/spaces/space_selector_drawer.dart';
import 'package:acter/features/events/model/keys.dart';
import 'package:acter/features/events/utils/events_utils.dart';
import 'package:acter/features/home/providers/client_providers.dart';
Expand Down Expand Up @@ -417,7 +417,11 @@ class CreateEventPageConsumerState extends ConsumerState<CreateEventPage> {
Future<void> _handleCreateEvent() async {
final lang = L10n.of(context);
String? spaceId = ref.read(selectedSpaceIdProvider);
spaceId ??= await selectSpace();
spaceId ??= await selectSpace(
context: context,
ref: ref,
canCheck: 'CanPostEvent',
);
if (!mounted) return;

if (spaceId == null) {
Expand Down Expand Up @@ -487,15 +491,4 @@ class CreateEventPageConsumerState extends ConsumerState<CreateEventPage> {
);
}
}

Future<String?> selectSpace() async {
final newSelectedSpaceId = await selectSpaceDrawer(
context: context,
currentSpaceId: ref.read(selectedSpaceIdProvider),
canCheck: 'CanPostEvent',
title: Text(L10n.of(context).selectSpace),
);
ref.read(selectedSpaceIdProvider.notifier).state = newSelectedSpaceId;
return newSelectedSpaceId;
}
}
13 changes: 6 additions & 7 deletions app/lib/features/home/widgets/quick_action_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:acter/common/themes/colors/color_scheme.dart';
import 'package:acter/common/utils/routes.dart';
import 'package:acter/common/widgets/action_button_widget.dart';
import 'package:acter/features/main/providers/main_providers.dart';
import 'package:acter/features/tasks/sheets/create_update_task_list.dart';
import 'package:acter/features/tasks/actions/create_task.dart';
import 'package:atlas_icons/atlas_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
Expand Down Expand Up @@ -42,10 +42,9 @@ class QuickActionButtons extends ConsumerWidget {
final canAddEvent =
ref.watch(hasSpaceWithPermissionProvider('CanPostEvent')).valueOrNull ??
false;
final canAddTask = ref
.watch(hasSpaceWithPermissionProvider('CanPostTaskList'))
.valueOrNull ??
false;
final canAddTask =
ref.watch(hasSpaceWithPermissionProvider('CanPostTask')).valueOrNull ??
false;
final canAddBoost =
ref.watch(hasSpaceWithPermissionProvider('CanPostNews')).valueOrNull ??
false;
Expand All @@ -64,12 +63,12 @@ class QuickActionButtons extends ConsumerWidget {
if (canAddTask)
ActionButtonWidget(
iconData: Atlas.list,
title: lang.addTaskList,
title: lang.addTask,
color: taskFeatureColor,
padding: const EdgeInsets.symmetric(vertical: 6),
onPressed: () {
ref.read(quickActionVisibilityProvider.notifier).state = false;
showCreateUpdateTaskListBottomSheet(context);
showCreateTaskBottomSheet(context);
},
),
if (canAddEvent)
Expand Down
13 changes: 6 additions & 7 deletions app/lib/features/home/widgets/sidebar_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:acter/features/bug_report/providers/bug_report_providers.dart';
import 'package:acter/features/home/data/keys.dart';
import 'package:acter/features/home/widgets/activities_icon.dart';
import 'package:acter/features/home/widgets/chats_icon.dart';
import 'package:acter/features/tasks/sheets/create_update_task_list.dart';
import 'package:acter/features/tasks/actions/create_task.dart';
import 'package:acter/router/providers/router_providers.dart';
import 'package:acter/router/utils.dart';
import 'package:acter_avatar/acter_avatar.dart';
Expand Down Expand Up @@ -231,10 +231,9 @@ class SidebarWidget extends ConsumerWidget {
final canAddEvent =
ref.watch(hasSpaceWithPermissionProvider('CanPostEvent')).valueOrNull ??
false;
final canAddTask = ref
.watch(hasSpaceWithPermissionProvider('CanPostTaskList'))
.valueOrNull ??
false;
final canAddTask =
ref.watch(hasSpaceWithPermissionProvider('CanPostTask')).valueOrNull ??
false;
final canAddBoost =
ref.watch(hasSpaceWithPermissionProvider('CanPostNews')).valueOrNull ??
false;
Expand All @@ -258,11 +257,11 @@ class SidebarWidget extends ConsumerWidget {
PopupMenuItem(
child: ActionButtonWidget(
iconData: Atlas.list,
title: lang.addTaskList,
title: lang.addTask,
color: taskFeatureColor,
onPressed: () {
if (context.canPop()) Navigator.pop(context);
showCreateUpdateTaskListBottomSheet(context);
showCreateTaskBottomSheet(context);
},
),
),
Expand Down
49 changes: 32 additions & 17 deletions app/lib/features/home/widgets/space_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,62 @@ import 'package:skeletonizer/skeletonizer.dart';
class SpaceChip extends ConsumerWidget {
final String spaceId;
final bool onTapOpenSpaceDetail;
final bool useCompatView;
final bool useCompactView;
final VoidCallback? onTapSelectSpace;

const SpaceChip({
super.key,
required this.spaceId,
this.onTapOpenSpaceDetail = true,
this.useCompatView = false,
this.useCompactView = false,
this.onTapSelectSpace,
});

@override
Widget build(BuildContext context, WidgetRef ref) {
if (useCompatView) {
if (useCompactView) {
return renderCompactView(context, ref);
}
return renderFullChip(context, ref);
}

static Widget loading() {
return Skeletonizer(
child: Chip(
avatar: ActerAvatar(
options: const AvatarOptions(
AvatarInfo(uniqueId: 'unique Id'),
size: 24,
static Widget loading({useCompactView = false}) =>
useCompactView ? loadingCompact() : loadingFull();

static Widget loadingFull() => Skeletonizer(
child: Chip(
avatar: ActerAvatar(
options: const AvatarOptions(
AvatarInfo(uniqueId: 'unique Id'),
size: 24,
),
),
label: const Text('unique name'),
),
label: const Text('unique name'),
),
);
}
);

static Widget loadingCompact() => const Skeletonizer(
child: Wrap(
children: [
Text('In: '),
SizedBox(width: 4),
Text('displayName'),
],
),
);

Widget renderCompactView(BuildContext context, WidgetRef ref) {
final lang = L10n.of(context);
final displayName =
ref.watch(roomDisplayNameProvider(spaceId)).valueOrNull ?? spaceId;
return Row(
return Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Text(lang.inSpaceLabelInline),
Text(lang.colonCharacter),
Text(
lang.inSpaceLabelInline,
style: Theme.of(context).textTheme.labelLarge,
),
const SizedBox(width: 4),
InkWell(
onTap: () {
if (onTapOpenSpaceDetail) {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/features/pins/pages/create_pin_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class _CreatePinConsumerState extends ConsumerState<CreatePinPage> {
alignment: Alignment.centerLeft,
child: SelectSpaceFormField(
canCheck: 'CanPostPin',
useCompatView: true,
useCompactView: true,
),
),
const SizedBox(height: 14),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/features/pins/pages/pin_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class _PinDetailsPageState extends ConsumerState<PinDetailsPage> {
Widget pinSpaceNameUI(ActerPin pin) {
return SpaceChip(
spaceId: pin.roomIdStr(),
useCompatView: true,
useCompactView: true,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final tabsProvider =
}

if (appSettings.tasks().active()) {
final taskList = await ref.watch(taskListProvider(spaceId).future);
final taskList = await ref.watch(taskListsProvider(spaceId).future);
if (taskList.isNotEmpty) {
tabs.add(TabEntry.tasks);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TasksSection extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final lang = L10n.of(context);
final tasksLoader = ref.watch(taskListProvider(spaceId));
final tasksLoader = ref.watch(taskListsProvider(spaceId));
return tasksLoader.when(
data: (tasks) => buildTasksSectionUI(context, tasks),
error: (e, s) {
Expand Down
Loading

0 comments on commit b937d58

Please sign in to comment.