mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-09 07:28:14 -07:00
Small improvements
This commit is contained in:
parent
86ff355e21
commit
b17a74bb23
10 changed files with 81 additions and 20 deletions
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
|
@ -81,7 +81,6 @@
|
||||||
"args": [
|
"args": [
|
||||||
"--web-port",
|
"--web-port",
|
||||||
"9090",
|
"9090",
|
||||||
"--web-experimental-hot-reload"
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -93,7 +92,6 @@
|
||||||
"args": [
|
"args": [
|
||||||
"--web-port",
|
"--web-port",
|
||||||
"9090",
|
"9090",
|
||||||
"--web-experimental-hot-reload"
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -1284,5 +1284,10 @@
|
||||||
"type": "int"
|
"type": "int"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"syncPauseAll": "Pause all",
|
||||||
|
"syncResumeAll": "Resume all",
|
||||||
|
"syncStopAll": "Stop all",
|
||||||
|
"syncDeleteAll": "Delete all files",
|
||||||
|
"syncAllFiles": "Sync all files"
|
||||||
}
|
}
|
||||||
|
|
@ -9,7 +9,6 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:dynamic_color/dynamic_color.dart';
|
import 'package:dynamic_color/dynamic_color.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:path/path.dart' as path;
|
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:smtc_windows/smtc_windows.dart' if (dart.library.html) 'package:fladder/stubs/web/smtc_web.dart';
|
import 'package:smtc_windows/smtc_windows.dart' if (dart.library.html) 'package:fladder/stubs/web/smtc_web.dart';
|
||||||
|
|
@ -69,13 +68,10 @@ void main(List<String> args) async {
|
||||||
|
|
||||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||||
|
|
||||||
Directory isarPath = Directory("");
|
|
||||||
Directory applicationDirectory = Directory("");
|
Directory applicationDirectory = Directory("");
|
||||||
|
|
||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
applicationDirectory = await getApplicationDocumentsDirectory();
|
applicationDirectory = await getApplicationDocumentsDirectory();
|
||||||
isarPath = Directory(path.joinAll([applicationDirectory.path, 'Fladder', 'Database']));
|
|
||||||
await isarPath.create(recursive: true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isDesktop) {
|
if (_isDesktop) {
|
||||||
|
|
@ -96,10 +92,7 @@ void main(List<String> args) async {
|
||||||
applicationInfoProvider.overrideWith((ref) => applicationInfo),
|
applicationInfoProvider.overrideWith((ref) => applicationInfo),
|
||||||
crashLogProvider.overrideWith((ref) => crashProvider),
|
crashLogProvider.overrideWith((ref) => crashProvider),
|
||||||
argumentsStateProvider.overrideWith((ref) => ArgumentsModel.fromArguments(args)),
|
argumentsStateProvider.overrideWith((ref) => ArgumentsModel.fromArguments(args)),
|
||||||
syncProvider.overrideWith((ref) => SyncNotifier(
|
syncProvider.overrideWith((ref) => SyncNotifier(ref, applicationDirectory))
|
||||||
ref,
|
|
||||||
applicationDirectory,
|
|
||||||
))
|
|
||||||
],
|
],
|
||||||
child: AdaptiveLayoutBuilder(
|
child: AdaptiveLayoutBuilder(
|
||||||
child: (context) => const Main(),
|
child: (context) => const Main(),
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class DatabaseItems extends Table {
|
||||||
TextColumn get userData => text().nullable()();
|
TextColumn get userData => text().nullable()();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Set<Column<Object>> get primaryKey => {id};
|
Set<Column<Object>> get primaryKey => {id, userId};
|
||||||
}
|
}
|
||||||
|
|
||||||
@DriftDatabase(tables: [DatabaseItems])
|
@DriftDatabase(tables: [DatabaseItems])
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ class $DatabaseItemsTable extends DatabaseItems
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Set<GeneratedColumn> get $primaryKey => {id};
|
Set<GeneratedColumn> get $primaryKey => {id, userId};
|
||||||
@override
|
@override
|
||||||
DatabaseItem map(Map<String, dynamic> data, {String? tablePrefix}) {
|
DatabaseItem map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||||
|
|
|
||||||
|
|
@ -669,6 +669,7 @@ extension SyncNotifierHelpers on SyncNotifier {
|
||||||
|
|
||||||
for (var i = 0; i < itemsToDownload.length; i++) {
|
for (var i = 0; i < itemsToDownload.length; i++) {
|
||||||
final item = itemsToDownload[i];
|
final item = itemsToDownload[i];
|
||||||
|
//No need to await file sync happens in the background
|
||||||
syncFile(item, false);
|
syncFile(item, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
|
|
@ -91,7 +92,7 @@ class HomeScreen extends ConsumerWidget {
|
||||||
action: () => e.navigate(context),
|
action: () => e.navigate(context),
|
||||||
);
|
);
|
||||||
case HomeTabs.sync:
|
case HomeTabs.sync:
|
||||||
if (canDownload) {
|
if (canDownload && !kIsWeb) {
|
||||||
return DestinationModel(
|
return DestinationModel(
|
||||||
label: context.localized.navigationSync,
|
label: context.localized.navigationSync,
|
||||||
icon: Icon(e.icon),
|
icon: Icon(e.icon),
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ class SeasonPoster extends ConsumerWidget {
|
||||||
items: season.generateActions(context, ref).popupMenuItems(useIcons: true));
|
items: season.generateActions(context, ref).popupMenuItems(useIcons: true));
|
||||||
},
|
},
|
||||||
onTap: () => onSeasonPressed?.call(season),
|
onTap: () => onSeasonPressed?.call(season),
|
||||||
onLongPress: AdaptiveLayout.of(context).inputDevice != InputDevice.touch
|
onLongPress: AdaptiveLayout.of(context).inputDevice == InputDevice.touch
|
||||||
? () {
|
? () {
|
||||||
showBottomSheetPill(
|
showBottomSheetPill(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:iconsax_plus/iconsax_plus.dart';
|
import 'package:iconsax_plus/iconsax_plus.dart';
|
||||||
|
|
||||||
import 'package:fladder/models/syncing/sync_item.dart';
|
import 'package:fladder/models/syncing/sync_item.dart';
|
||||||
|
import 'package:fladder/providers/sync/background_download_provider.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/sync_provider.dart';
|
||||||
import 'package:fladder/util/localization_helper.dart';
|
import 'package:fladder/util/localization_helper.dart';
|
||||||
|
|
@ -33,7 +34,23 @@ class SyncOptionsButton extends ConsumerWidget {
|
||||||
|
|
||||||
final syncedChildren =
|
final syncedChildren =
|
||||||
children.where((element) => element.hasVideoFile && element.videoFile.existsSync()).toList();
|
children.where((element) => element.hasVideoFile && element.videoFile.existsSync()).toList();
|
||||||
return [
|
|
||||||
|
final syncTasks = children
|
||||||
|
.map((element) {
|
||||||
|
final task = ref.read(syncDownloadStatusProvider(element, []));
|
||||||
|
if (task?.status != TaskStatus.notFound) {
|
||||||
|
return task;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.nonNulls
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
final runningTasks = syncTasks.where((element) => element.status == TaskStatus.running).toList();
|
||||||
|
final enqueuedTasks = syncTasks.where((element) => element.status == TaskStatus.enqueued).toList();
|
||||||
|
final pausedTasks = syncTasks.where((element) => element.status == TaskStatus.paused).toList();
|
||||||
|
return <PopupMenuEntry>[
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Row(
|
child: Row(
|
||||||
spacing: 12,
|
spacing: 12,
|
||||||
|
|
@ -45,13 +62,14 @@ class SyncOptionsButton extends ConsumerWidget {
|
||||||
onTap: () => context.refreshData(),
|
onTap: () => context.refreshData(),
|
||||||
),
|
),
|
||||||
if (children.isNotEmpty) ...[
|
if (children.isNotEmpty) ...[
|
||||||
|
const PopupMenuDivider(),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
enabled: unSyncedChildren.isNotEmpty,
|
enabled: unSyncedChildren.isNotEmpty,
|
||||||
child: Row(
|
child: Row(
|
||||||
spacing: 12,
|
spacing: 12,
|
||||||
children: [
|
children: [
|
||||||
const Icon(IconsaxPlusLinear.cloud_add),
|
const Icon(IconsaxPlusLinear.cloud_add),
|
||||||
Text(context.localized.sync),
|
Text(context.localized.syncAllFiles),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onTap: () async => _syncRemainingItems(context, syncedItem, unSyncedChildren, ref),
|
onTap: () async => _syncRemainingItems(context, syncedItem, unSyncedChildren, ref),
|
||||||
|
|
@ -62,11 +80,54 @@ class SyncOptionsButton extends ConsumerWidget {
|
||||||
spacing: 12,
|
spacing: 12,
|
||||||
children: [
|
children: [
|
||||||
const Icon(IconsaxPlusLinear.trash),
|
const Icon(IconsaxPlusLinear.trash),
|
||||||
Text(context.localized.delete),
|
Text(context.localized.syncDeleteAll),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onTap: () async => _deleteSyncedItems(context, syncedItem, syncedChildren, ref),
|
onTap: () async => _deleteSyncedItems(context, syncedItem, syncedChildren, ref),
|
||||||
)
|
),
|
||||||
|
const PopupMenuDivider(),
|
||||||
|
PopupMenuItem(
|
||||||
|
enabled: pausedTasks.isNotEmpty,
|
||||||
|
child: Row(
|
||||||
|
spacing: 12,
|
||||||
|
children: [
|
||||||
|
const Icon(IconsaxPlusLinear.play),
|
||||||
|
Text(context.localized.syncResumeAll),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () => ref
|
||||||
|
.read(backgroundDownloaderProvider)
|
||||||
|
.resumeAll(tasks: pausedTasks.map((e) => e.task).nonNulls.toList()),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
enabled: runningTasks.isNotEmpty,
|
||||||
|
child: Row(
|
||||||
|
spacing: 12,
|
||||||
|
children: [
|
||||||
|
const Icon(IconsaxPlusLinear.pause),
|
||||||
|
Text(context.localized.syncPauseAll),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
ref
|
||||||
|
.read(backgroundDownloaderProvider)
|
||||||
|
.pauseAll(tasks: runningTasks.map((e) => e.task).nonNulls.toList());
|
||||||
|
},
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
enabled: [...runningTasks, ...pausedTasks, ...enqueuedTasks].isNotEmpty,
|
||||||
|
child: Row(
|
||||||
|
spacing: 12,
|
||||||
|
children: [
|
||||||
|
const Icon(IconsaxPlusLinear.stop),
|
||||||
|
Text(context.localized.syncStopAll),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
ref.read(backgroundDownloaderProvider).cancelAll(
|
||||||
|
tasks: [...runningTasks, ...pausedTasks, ...enqueuedTasks].map((e) => e.task).nonNulls.toList());
|
||||||
|
},
|
||||||
|
),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@ extension RefreshContextExtension on BuildContext {
|
||||||
Future<void> refreshData() async {
|
Future<void> refreshData() async {
|
||||||
//Small delay to fix server not updating response based on successful query
|
//Small delay to fix server not updating response based on successful query
|
||||||
await Future.delayed(const Duration(milliseconds: 250));
|
await Future.delayed(const Duration(milliseconds: 250));
|
||||||
await RefreshState.maybeOf(this)?.refresh();
|
if (mounted) {
|
||||||
|
await RefreshState.maybeOf(this)?.refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue