mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-14 01:37:07 -07:00
feat: Add sync button to top right in details view
This commit is contained in:
parent
5a5a4e4703
commit
cef39347c1
1 changed files with 24 additions and 7 deletions
|
|
@ -7,6 +7,8 @@ import 'package:iconsax_plus/iconsax_plus.dart';
|
||||||
import 'package:fladder/models/item_base_model.dart';
|
import 'package:fladder/models/item_base_model.dart';
|
||||||
import 'package:fladder/models/items/images_models.dart';
|
import 'package:fladder/models/items/images_models.dart';
|
||||||
import 'package:fladder/providers/sync/sync_provider_helpers.dart';
|
import 'package:fladder/providers/sync/sync_provider_helpers.dart';
|
||||||
|
import 'package:fladder/providers/sync_provider.dart';
|
||||||
|
import 'package:fladder/providers/user_provider.dart';
|
||||||
import 'package:fladder/routes/auto_router.gr.dart';
|
import 'package:fladder/routes/auto_router.gr.dart';
|
||||||
import 'package:fladder/screens/syncing/sync_button.dart';
|
import 'package:fladder/screens/syncing/sync_button.dart';
|
||||||
import 'package:fladder/screens/syncing/sync_item_details.dart';
|
import 'package:fladder/screens/syncing/sync_item_details.dart';
|
||||||
|
|
@ -205,13 +207,25 @@ class _DetailScaffoldState extends ConsumerState<DetailScaffold> {
|
||||||
ref.watch(syncedItemProvider(widget.item)).when(
|
ref.watch(syncedItemProvider(widget.item)).when(
|
||||||
error: (error, stackTrace) => const SizedBox.shrink(),
|
error: (error, stackTrace) => const SizedBox.shrink(),
|
||||||
data: (syncedItem) {
|
data: (syncedItem) {
|
||||||
if (syncedItem == null) {
|
if (syncedItem == null &&
|
||||||
return const SizedBox.shrink();
|
ref.read(userProvider.select(
|
||||||
|
(value) => value?.canDownload ?? false,
|
||||||
|
)) &&
|
||||||
|
widget.item?.syncAble == true) {
|
||||||
|
return IconButton(
|
||||||
|
onPressed: () =>
|
||||||
|
ref.read(syncProvider.notifier).addSyncItem(context, widget.item!),
|
||||||
|
icon: const Icon(
|
||||||
|
IconsaxPlusLinear.arrow_down_2,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (syncedItem != null) {
|
||||||
|
return IconButton(
|
||||||
|
onPressed: () => showSyncItemDetails(context, syncedItem, ref),
|
||||||
|
icon: SyncButton(item: widget.item!, syncedItem: syncedItem),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return IconButton(
|
return const SizedBox.shrink();
|
||||||
onPressed: () => showSyncItemDetails(context, syncedItem, ref),
|
|
||||||
icon: SyncButton(item: widget.item!, syncedItem: syncedItem),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
loading: () => const SizedBox.shrink(),
|
loading: () => const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
|
|
@ -222,7 +236,10 @@ class _DetailScaffoldState extends ConsumerState<DetailScaffold> {
|
||||||
return PopupMenuButton(
|
return PopupMenuButton(
|
||||||
tooltip: context.localized.moreOptions,
|
tooltip: context.localized.moreOptions,
|
||||||
enabled: newActions?.isNotEmpty == true,
|
enabled: newActions?.isNotEmpty == true,
|
||||||
icon: Icon(widget.item!.type.icon),
|
icon: Icon(
|
||||||
|
widget.item!.type.icon,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
itemBuilder: (context) => newActions?.popupMenuItems(useIcons: true) ?? [],
|
itemBuilder: (context) => newActions?.popupMenuItems(useIcons: true) ?? [],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue