mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-13 09:20:31 -07:00
Init repo
This commit is contained in:
commit
764b6034e3
566 changed files with 212335 additions and 0 deletions
123
lib/screens/metadata/refresh_metadata.dart
Normal file
123
lib/screens/metadata/refresh_metadata.dart
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
import 'package:fladder/jellyfin/enum_models.dart';
|
||||
import 'package:fladder/providers/user_provider.dart';
|
||||
import 'package:fladder/screens/settings/settings_list_tile.dart';
|
||||
import 'package:fladder/screens/shared/fladder_snackbar.dart';
|
||||
import 'package:fladder/util/adaptive_layout.dart';
|
||||
import 'package:fladder/util/localization_helper.dart';
|
||||
import 'package:fladder/widgets/shared/enum_selection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
Future<void> showRefreshPopup(BuildContext context, String itemId, String itemName) async {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => RefreshPopupDialog(
|
||||
itemId: itemId,
|
||||
name: itemName,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class RefreshPopupDialog extends ConsumerStatefulWidget {
|
||||
final String itemId;
|
||||
final String name;
|
||||
|
||||
const RefreshPopupDialog({required this.itemId, required this.name, super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<ConsumerStatefulWidget> createState() => _RefreshPopupDialogState();
|
||||
}
|
||||
|
||||
class _RefreshPopupDialogState extends ConsumerState<RefreshPopupDialog> {
|
||||
MetadataRefresh refreshMode = MetadataRefresh.defaultRefresh;
|
||||
bool replaceAllMetadata = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
child: Card(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: AdaptiveLayout.of(context).inputDevice == InputDevice.pointer ? 700 : double.infinity),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
context.localized.refreshPopup(widget.name),
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
EnumBox(
|
||||
current: refreshMode.label(context),
|
||||
itemBuilder: (context) => MetadataRefresh.values
|
||||
.map((value) => PopupMenuItem(
|
||||
value: value,
|
||||
child: Text(value.label(context)),
|
||||
onTap: () => setState(() {
|
||||
refreshMode = value;
|
||||
}),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
if (refreshMode != MetadataRefresh.defaultRefresh)
|
||||
SettingsListTile(
|
||||
label: Text(context.localized.replaceExistingImages),
|
||||
trailing: Switch.adaptive(
|
||||
value: replaceAllMetadata,
|
||||
onChanged: (value) => setState(() => replaceAllMetadata = value),
|
||||
),
|
||||
),
|
||||
SettingsListTile(
|
||||
label: Text(
|
||||
context.localized.refreshPopupContentMetadata,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
FilledButton(
|
||||
onPressed: () async {
|
||||
final response = await ref.read(userProvider.notifier).refreshMetaData(
|
||||
widget.itemId,
|
||||
metadataRefreshMode: refreshMode,
|
||||
replaceAllMetadata: replaceAllMetadata,
|
||||
);
|
||||
if (!response.isSuccessful) {
|
||||
fladderSnackbarResponse(context, response);
|
||||
} else {
|
||||
fladderSnackbar(context, title: context.localized.scanningName(widget.name));
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(context.localized.refresh)),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue