mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-08 23:18:16 -07:00
feature: Improved sync capability
This commit is contained in:
parent
f3e920ac79
commit
c5c7f71b84
31 changed files with 500 additions and 344 deletions
|
|
@ -1,12 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:iconsax_plus/iconsax_plus.dart';
|
||||
|
||||
import 'package:fladder/models/item_base_model.dart';
|
||||
import 'package:fladder/models/syncing/sync_item.dart';
|
||||
import 'package:fladder/providers/sync/sync_provider_helpers.dart';
|
||||
import 'package:fladder/providers/sync_provider.dart';
|
||||
import 'package:fladder/screens/shared/default_alert_dialog.dart';
|
||||
import 'package:fladder/screens/syncing/sync_item_details.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class SyncButton extends ConsumerStatefulWidget {
|
||||
final ItemBaseModel item;
|
||||
|
|
@ -21,37 +20,21 @@ class _SyncButtonState extends ConsumerState<SyncButton> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final syncedItem = widget.syncedItem;
|
||||
final status = syncedItem != null ? ref.watch(syncStatusesProvider(syncedItem)).value : null;
|
||||
final progress = syncedItem != null ? ref.watch(syncDownloadStatusProvider(syncedItem)) : null;
|
||||
final status = syncedItem != null ? ref.watch(syncStatusesProvider(syncedItem, null)).value : null;
|
||||
final progress = syncedItem != null ? ref.watch(syncDownloadStatusProvider(syncedItem, [])) : null;
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: syncedItem != null
|
||||
? () => showSyncItemDetails(context, syncedItem, ref)
|
||||
: () => showDefaultActionDialog(
|
||||
context,
|
||||
'Sync ${widget.item.detailedName}?',
|
||||
null,
|
||||
(context) async {
|
||||
await ref.read(syncProvider.notifier).addSyncItem(context, widget.item);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
"Sync",
|
||||
(context) => Navigator.of(context).pop(),
|
||||
"Cancel",
|
||||
),
|
||||
child: Icon(
|
||||
syncedItem != null
|
||||
? status == SyncStatus.partially
|
||||
? (progress?.progress ?? 0) > 0
|
||||
? IconsaxPlusLinear.arrow_down
|
||||
: IconsaxPlusLinear.more_circle
|
||||
: IconsaxPlusLinear.tick_circle
|
||||
: IconsaxPlusLinear.arrow_down_2,
|
||||
color: status?.color,
|
||||
size: (progress?.progress ?? 0) > 0 ? 16 : null,
|
||||
),
|
||||
Icon(
|
||||
syncedItem != null
|
||||
? status == SyncStatus.partially
|
||||
? (progress?.progress ?? 0) > 0
|
||||
? IconsaxPlusLinear.arrow_down
|
||||
: IconsaxPlusLinear.more_circle
|
||||
: IconsaxPlusLinear.tick_circle
|
||||
: IconsaxPlusLinear.arrow_down_2,
|
||||
color: status?.color,
|
||||
size: (progress?.progress ?? 0) > 0 ? 16 : null,
|
||||
),
|
||||
if ((progress?.progress ?? 0) > 0)
|
||||
IgnorePointer(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue