Skip to content

Commit

Permalink
Merge pull request #2082 from acterglobal/kumar/pin-list-improvements
Browse files Browse the repository at this point in the history
Pin List Item UI-UX Improvements
  • Loading branch information
kumarpalsinh25 authored Aug 20, 2024
2 parents 5b995f5 + 7d465b4 commit f23e343
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 207 deletions.
15 changes: 2 additions & 13 deletions app/lib/features/pins/pages/pin_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:acter/features/pins/actions/reduct_pin_action.dart';
import 'package:acter/features/pins/actions/report_pin_action.dart';
import 'package:acter/features/pins/providers/pins_provider.dart';
import 'package:acter/features/pins/widgets/fake_link_attachment_item.dart';
import 'package:acter/features/pins/widgets/pin_icon.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:atlas_icons/atlas_icons.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -184,7 +185,7 @@ class _PinDetailsPageState extends ConsumerState<PinDetailsPage> {
children: [
Row(
children: [
pinIconUI(),
const PinIcon(),
const SizedBox(width: 12),
Expanded(
child: Column(
Expand All @@ -204,18 +205,6 @@ class _PinDetailsPageState extends ConsumerState<PinDetailsPage> {
);
}

Widget pinIconUI() {
return Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondary,
borderRadius: const BorderRadius.all(Radius.circular(100)),
),
child: const Icon(Atlas.pin),
);
}

Widget pinTitleUI(ActerPin pin) {
return SelectionArea(
child: GestureDetector(
Expand Down
4 changes: 2 additions & 2 deletions app/lib/features/pins/pages/pins_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:acter/common/widgets/add_button_with_can_permission.dart';
import 'package:acter/common/widgets/empty_state_widget.dart';
import 'package:acter/common/widgets/space_name_widget.dart';
import 'package:acter/features/pins/providers/pins_provider.dart';
import 'package:acter/features/pins/widgets/pin_list_item.dart';
import 'package:acter/features/pins/widgets/pin_list_item_widget.dart';
import 'package:acter/features/pins/widgets/pin_list_skeleton.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -115,7 +115,7 @@ class _AllPinsPageConsumerState extends ConsumerState<PinsListPage> {
crossAxisCount: max(1, min(widthCount, minCount)),
children: [
for (var pin in pins)
PinListItemById(
PinListItemWidget(
pinId: pin.eventIdStr(),
showSpace: widget.spaceId == null,
),
Expand Down
28 changes: 28 additions & 0 deletions app/lib/features/pins/widgets/pin_icon.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:atlas_icons/atlas_icons.dart';
import 'package:flutter/material.dart';

class PinIcon extends StatelessWidget {
final Color? iconColor;

const PinIcon({
super.key,
this.iconColor,
});

@override
Widget build(BuildContext context) {
return pinIconUI(context);
}

Widget pinIconUI(BuildContext context) {
return Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: iconColor ?? Theme.of(context).unselectedWidgetColor,
borderRadius: const BorderRadius.all(Radius.circular(100)),
),
child: const Icon(Atlas.pin),
);
}
}
189 changes: 0 additions & 189 deletions app/lib/features/pins/widgets/pin_list_item.dart

This file was deleted.

55 changes: 55 additions & 0 deletions app/lib/features/pins/widgets/pin_list_item_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import 'package:acter/common/utils/routes.dart';
import 'package:acter/common/widgets/space_name_widget.dart';
import 'package:acter/features/pins/providers/pins_provider.dart';
import 'package:acter/features/pins/widgets/pin_icon.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:logging/logging.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:skeletonizer/skeletonizer.dart';

final _log = Logger('a3::pins::pin_item');

class PinListItemWidget extends ConsumerWidget {
final String pinId;
final bool showSpace;

const PinListItemWidget({
required this.pinId,
this.showSpace = false,
super.key,
});

@override
Widget build(BuildContext context, WidgetRef ref) {
final pinData = ref.watch(pinProvider(pinId));
return pinData.when(
data: (pin) => buildPinItemUI(context, pin),
error: (e, s) {
_log.severe('Failed to load pin', e, s);
return Text(L10n.of(context).errorLoadingPin(e));
},
loading: () => const Skeletonizer(
child: SizedBox(height: 100, width: 100),
),
);
}

Widget buildPinItemUI(BuildContext context, ActerPin pin) {
return Card(
child: ListTile(
onTap: () => context.pushNamed(
Routes.pin.name,
pathParameters: {'pinId': pinId},
),
leading: const PinIcon(),
title: Text(pin.title(), overflow: TextOverflow.ellipsis),
subtitle: showSpace
? SpaceNameWidget(spaceId: pin.roomIdStr(), isShowBrackets: false)
: null,
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:acter/common/utils/routes.dart';
import 'package:acter/features/pins/providers/pins_provider.dart';
import 'package:acter/features/pins/widgets/pin_list_item.dart';
import 'package:acter/features/pins/widgets/pin_list_item_widget.dart';
import 'package:acter/features/space/widgets/space_sections/section_header.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -65,7 +65,7 @@ class PinsSection extends ConsumerWidget {
padding: EdgeInsets.zero,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return PinListItemById(pinId: pins[index].eventIdStr());
return PinListItemWidget(pinId: pins[index].eventIdStr());
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2125,5 +2125,5 @@
"pinDetails": "Pin Details",
"inSpaceLabelInline": "In",
"comingSoon": "Not supported yet, coming soon!",
"colonCharacter": ":"
"colonCharacter": " : "
}

0 comments on commit f23e343

Please sign in to comment.