From efc5918b9ccae361b0833003e61fd129355a7807 Mon Sep 17 00:00:00 2001 From: Abhishek Shroff Date: Wed, 22 Jan 2025 23:44:01 +0530 Subject: [PATCH] [client] Pending change indicators on list items --- .../lib/ui/explorer/resource_details_row.dart | 86 ++++++++++--------- .../ui/explorer/resource_drop_and_drop.dart | 2 +- client/pubspec.lock | 8 +- client/pubspec.yaml | 6 +- 4 files changed, 54 insertions(+), 48 deletions(-) diff --git a/client/lib/ui/explorer/resource_details_row.dart b/client/lib/ui/explorer/resource_details_row.dart index 57eeebc8..8582ce3a 100644 --- a/client/lib/ui/explorer/resource_details_row.dart +++ b/client/lib/ui/explorer/resource_details_row.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:phylum/libphylum/actions/action_resource.dart'; import 'package:phylum/libphylum/db/db.dart'; +import 'package:phylum/libphylum/phylum_api_types.dart'; import 'package:phylum/ui/explorer/resource_icon_extension.dart'; import 'package:phylum/util/file_size.dart'; import 'package:phylum/util/time.dart'; @@ -8,16 +10,18 @@ import 'package:provider/provider.dart'; import '../../libphylum/explorer/explorer_controller.dart'; class ResourceDetailsRow extends StatelessWidget { - final Resource r; + final Resource resource; final bool dropTargetActive; - ResourceDetailsRow({required this.r, required this.dropTargetActive}) : super(key: ValueKey(r.id)); + ResourceDetailsRow({required this.resource, required this.dropTargetActive}) : super(key: ValueKey(resource.id)); @override Widget build(BuildContext context) { - final showBorder = context.select((state) => state.focusId == r.id && state.showFocus); - final highlight = context.select((state) => state.isSelected(r.id)); - final dim = context.select((state) => state.isSelected(r.id) && state.dragging); + final showBorder = context.select((state) => state.focusId == resource.id && state.showFocus); + final highlight = context.select((state) => state.isSelected(resource.id)); + final dim = context.select((state) => state.isSelected(resource.id) && state.dragging); + final hasChanges = context.select( + (state) => state.actions.any((action) => action is ResourceAction && action.resourceId == resource.id)); final theme = Theme.of(context); final colorScheme = theme.colorScheme; final border = dropTargetActive @@ -26,14 +30,14 @@ class ResourceDetailsRow extends StatelessWidget { ? BorderSide(color: colorScheme.primary, width: 2.0) : const BorderSide(color: Colors.transparent, width: 2.0); String subtitle = ""; - if (r.modified != null) { - subtitle = r.modified!.formatForDisplay(); + if (resource.modified != null) { + subtitle = resource.modified!.formatForDisplay(); } - if (!r.dir) { + if (!resource.dir) { if (subtitle.isNotEmpty) { subtitle += " \u2022 "; } - subtitle += r.contentLength.formatForDisplay(); + subtitle += resource.contentLength.formatForDisplay(); } final color = highlight ? dim @@ -58,13 +62,13 @@ class ResourceDetailsRow extends StatelessWidget { children: [ Padding( padding: const EdgeInsets.symmetric(vertical: 9.0, horizontal: 16), - child: r.getIcon(), + child: resource.getIcon(), ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - r.name, + resource.name, maxLines: 1, softWrap: false, overflow: TextOverflow.fade, @@ -76,35 +80,39 @@ class ResourceDetailsRow extends StatelessWidget { : colorScheme.onSurface, ), ), - if (subtitle.isNotEmpty) - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - if (r.permissions != null) - Padding( - padding: const EdgeInsets.only(right: 6.0), - child: Icon(Icons.people_alt, size: 14), - ), - if (r.publinks != null) - Padding( - padding: const EdgeInsets.only(right: 6.0), - child: Icon(Icons.public, size: 14), - ), - Text( - subtitle, - maxLines: 1, - softWrap: false, - overflow: TextOverflow.fade, - style: theme.textTheme.bodyMedium!.copyWith( - color: highlight - ? dim - ? colorScheme.primary.withAlpha(192) - : colorScheme.primary - : colorScheme.onSurfaceVariant, - ), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (hasChanges) + const Padding( + padding: EdgeInsets.only(right: 6.0), + child: Icon(Icons.sync, size: 14), ), - ], - ), + if (resource.permissions != null) + const Padding( + padding: EdgeInsets.only(right: 6.0), + child: Icon(Icons.people_alt, size: 14), + ), + if (resource.publinks != null) + const Padding( + padding: EdgeInsets.only(right: 6.0), + child: Icon(Icons.public, size: 14), + ), + Text( + subtitle, + maxLines: 1, + softWrap: false, + overflow: TextOverflow.fade, + style: theme.textTheme.bodyMedium!.copyWith( + color: highlight + ? dim + ? colorScheme.primary.withAlpha(192) + : colorScheme.primary + : colorScheme.onSurfaceVariant, + ), + ), + ], + ), ], ), ], diff --git a/client/lib/ui/explorer/resource_drop_and_drop.dart b/client/lib/ui/explorer/resource_drop_and_drop.dart index e3479d0c..b60e80b8 100644 --- a/client/lib/ui/explorer/resource_drop_and_drop.dart +++ b/client/lib/ui/explorer/resource_drop_and_drop.dart @@ -202,7 +202,7 @@ class ResourceDraggable extends StatelessWidget { ); }), child: ResourceDetailsRow( - r: resource, + resource: resource, dropTargetActive: dropTargetActive, ), ); diff --git a/client/pubspec.lock b/client/pubspec.lock index b311c2e2..6d03bacd 100644 --- a/client/pubspec.lock +++ b/client/pubspec.lock @@ -616,9 +616,11 @@ packages: offtheline: dependency: "direct main" description: - path: "../../offtheline" - relative: true - source: path + path: "." + ref: b25d6ded81b50e72cb24df9ab2d288f2c41f969b + resolved-ref: b25d6ded81b50e72cb24df9ab2d288f2c41f969b + url: "https://codeberg.org/shroff/offtheline.git" + source: git version: "0.16.0" open_file: dependency: "direct main" diff --git a/client/pubspec.yaml b/client/pubspec.yaml index f1abe276..612d74e2 100644 --- a/client/pubspec.yaml +++ b/client/pubspec.yaml @@ -24,7 +24,7 @@ dependencies: offtheline: git: url: https://codeberg.org/shroff/offtheline.git - ref: b26c970813893fef5de721b9e140cfaeec2a6cb1 + ref: b25d6ded81b50e72cb24df9ab2d288f2c41f969b open_file: path: path_provider: @@ -44,9 +44,5 @@ dev_dependencies: drift_dev: ^2.19.1 build_runner: ^2.4.12 -dependency_overrides: - offtheline: - path: ../../offtheline - flutter: uses-material-design: true \ No newline at end of file