119 lines
4.2 KiB
Dart
119 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:worldhopper/providers/filter_quality_provider.dart';
|
|
import 'package:worldhopper/providers/precache_pages_provider.dart';
|
|
import 'package:worldhopper/providers/reading_mode_provider.dart';
|
|
import 'package:worldhopper/screens/settings/filter_quality_settings_screen.dart';
|
|
import 'package:worldhopper/screens/settings/precache_pages_settings_screen.dart';
|
|
import 'package:worldhopper/screens/settings/reading_mode_settings_screen.dart';
|
|
import 'package:worldhopper/widgets/worldhopper_app_bar.dart';
|
|
|
|
/// Screen for reader-related settings
|
|
class ReadersSettingsScreen extends ConsumerWidget {
|
|
const ReadersSettingsScreen({super.key});
|
|
|
|
static const _readingModeLabels = <ReadingMode, String>{
|
|
ReadingMode.ltr: 'Left to right',
|
|
ReadingMode.rtl: 'Right to left',
|
|
ReadingMode.verticalContinuous: 'Vertical scroll',
|
|
};
|
|
|
|
static const _filterQualityLabels = <FilterQuality, String>{
|
|
FilterQuality.none: 'None',
|
|
FilterQuality.low: 'Low',
|
|
FilterQuality.medium: 'Medium',
|
|
FilterQuality.high: 'High',
|
|
};
|
|
|
|
static const _precachePagesLabels = <int, String>{
|
|
0: 'Off',
|
|
1: '1 page',
|
|
2: '2 pages',
|
|
3: '3 pages',
|
|
4: '4 pages',
|
|
5: '5 pages',
|
|
};
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final readingMode = ref.watch(readingModeNotifierProvider);
|
|
final filterQuality = ref.watch(filterQualityNotifierProvider);
|
|
final precachePages = ref.watch(precachePagesNotifierProvider);
|
|
|
|
return Scaffold(
|
|
appBar: const WorldhopperAppBar(
|
|
title: Text('Readers'),
|
|
),
|
|
body: ListView(
|
|
children: [
|
|
_buildSectionHeader(context, 'Image Reader'),
|
|
Card(
|
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Column(
|
|
children: [
|
|
ListTile(
|
|
leading: const Icon(Icons.chrome_reader_mode_outlined),
|
|
title: const Text('Reading direction'),
|
|
subtitle:
|
|
Text(_readingModeLabels[readingMode] ?? 'Left to right'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () {
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(
|
|
builder: (_) => const ReadingModeSettingsScreen(),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
const Divider(height: 1),
|
|
ListTile(
|
|
leading: const Icon(Icons.high_quality_outlined),
|
|
title: const Text('Filter quality'),
|
|
subtitle:
|
|
Text(_filterQualityLabels[filterQuality] ?? 'Medium'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () {
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(
|
|
builder: (_) => const FilterQualitySettingsScreen(),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
const Divider(height: 1),
|
|
ListTile(
|
|
leading: const Icon(Icons.cached_outlined),
|
|
title: const Text('Pre-cache pages'),
|
|
subtitle: Text(
|
|
_precachePagesLabels[precachePages] ?? '$precachePages pages'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () {
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(
|
|
builder: (_) => const PrecachePagesSettingsScreen(),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildSectionHeader(BuildContext context, String title) {
|
|
return Padding(
|
|
padding: const EdgeInsets.fromLTRB(32, 24, 16, 8),
|
|
child: Text(
|
|
title,
|
|
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
|
color: Theme.of(context).colorScheme.primary,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|