mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-05-14 03:00:38 +00:00
114 lines
4.5 KiB
Dart
114 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:mangayomi/modules/more/settings/downloads/providers/downloads_state_provider.dart';
|
|
import 'package:mangayomi/providers/l10n_providers.dart';
|
|
import 'package:mangayomi/utils/extensions/build_context_extensions.dart';
|
|
import 'package:numberpicker/numberpicker.dart';
|
|
|
|
class DownloadsScreen extends ConsumerStatefulWidget {
|
|
const DownloadsScreen({super.key});
|
|
|
|
@override
|
|
ConsumerState<DownloadsScreen> createState() => _DownloadsScreenState();
|
|
}
|
|
|
|
class _DownloadsScreenState extends ConsumerState<DownloadsScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final saveAsCBZArchiveState = ref.watch(saveAsCBZArchiveStateProvider);
|
|
final onlyOnWifiState = ref.watch(onlyOnWifiStateProvider);
|
|
final concurrentDownloads = ref.watch(concurrentDownloadsStateProvider);
|
|
final l10n = l10nLocalizations(context);
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text(l10n!.downloads)),
|
|
body: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
SwitchListTile(
|
|
value: onlyOnWifiState,
|
|
title: Text(l10n.only_on_wifi),
|
|
onChanged: (value) {
|
|
ref.read(onlyOnWifiStateProvider.notifier).set(value);
|
|
},
|
|
),
|
|
SwitchListTile(
|
|
value: saveAsCBZArchiveState,
|
|
title: Text(l10n.save_as_cbz_archive),
|
|
onChanged: (value) {
|
|
ref.read(saveAsCBZArchiveStateProvider.notifier).set(value);
|
|
},
|
|
),
|
|
ListTile(
|
|
onTap: () {
|
|
int currentIntValue = concurrentDownloads;
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return AlertDialog(
|
|
title: Text(context.l10n.concurrent_downloads),
|
|
content: StatefulBuilder(
|
|
builder: (context, setState) => SizedBox(
|
|
height: 200,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
NumberPicker(
|
|
value: currentIntValue,
|
|
minValue: 1,
|
|
maxValue: 255,
|
|
step: 1,
|
|
haptics: true,
|
|
textMapper: (numberText) => numberText,
|
|
onChanged: (value) =>
|
|
setState(() => currentIntValue = value),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
actions: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
TextButton(
|
|
onPressed: () async {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Text(
|
|
context.l10n.cancel,
|
|
style: TextStyle(color: context.primaryColor),
|
|
),
|
|
),
|
|
TextButton(
|
|
onPressed: () async {
|
|
ref
|
|
.read(
|
|
concurrentDownloadsStateProvider.notifier,
|
|
)
|
|
.set(currentIntValue);
|
|
Navigator.pop(context);
|
|
},
|
|
child: Text(
|
|
context.l10n.ok,
|
|
style: TextStyle(color: context.primaryColor),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
},
|
|
title: Text(context.l10n.concurrent_downloads),
|
|
subtitle: Text(
|
|
"$concurrentDownloads",
|
|
style: TextStyle(fontSize: 11, color: context.secondaryColor),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|