init
This commit is contained in:
commit
d205277cdd
182 changed files with 22978 additions and 0 deletions
174
lib/screens/settings_screen.dart
Normal file
174
lib/screens/settings_screen.dart
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../settings/settings_store.dart';
|
||||
import '../theme/tokens.dart';
|
||||
import '../widgets/hairline_panel.dart';
|
||||
|
||||
/// Audio-quality settings: independent streaming and download knobs, both
|
||||
/// driven by Subsonic's `stream` transcode params (see `settings/settings_store.dart`).
|
||||
class SettingsScreen extends ConsumerWidget {
|
||||
const SettingsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final settings = ref.watch(settingsProvider);
|
||||
final controller = ref.read(settingsProvider.notifier);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Settings',
|
||||
style: TextStyle(fontWeight: FontWeight.w700)),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(RatuneSpacing.lg),
|
||||
children: [
|
||||
HairlinePanel(
|
||||
title: 'Streaming',
|
||||
active: true,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const _Caption(
|
||||
'Quality used when playing tracks that are not downloaded.'),
|
||||
const SizedBox(height: RatuneSpacing.md),
|
||||
_ChoiceChips<int>(
|
||||
label: 'Max bitrate',
|
||||
values: AppSettings.bitrateChoices,
|
||||
selected: settings.streamMaxBitRate,
|
||||
labelFor: AppSettings.bitrateLabel,
|
||||
onSelect: controller.setStreamMaxBitRate,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: RatuneSpacing.xl),
|
||||
HairlinePanel(
|
||||
title: 'Downloads',
|
||||
active: true,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const _Caption(
|
||||
'Quality used when saving tracks for offline playback. '
|
||||
'"Original" keeps the source file (best quality, largest).'),
|
||||
const SizedBox(height: RatuneSpacing.md),
|
||||
_ChoiceChips<int>(
|
||||
label: 'Max bitrate',
|
||||
values: AppSettings.bitrateChoices,
|
||||
selected: settings.downloadMaxBitRate,
|
||||
labelFor: AppSettings.bitrateLabel,
|
||||
onSelect: controller.setDownloadMaxBitRate,
|
||||
),
|
||||
const SizedBox(height: RatuneSpacing.lg),
|
||||
_ChoiceChips<String?>(
|
||||
label: 'Format',
|
||||
values: AppSettings.formatChoices,
|
||||
selected: settings.downloadFormat,
|
||||
labelFor: AppSettings.formatLabel,
|
||||
onSelect: controller.setDownloadFormat,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Caption extends StatelessWidget {
|
||||
const _Caption(this.text);
|
||||
final String text;
|
||||
@override
|
||||
Widget build(BuildContext context) => Text(
|
||||
text,
|
||||
style: const TextStyle(color: RatuneColors.dimmed, fontSize: 12),
|
||||
);
|
||||
}
|
||||
|
||||
/// A labelled row of selectable value chips — the app's underline-accent
|
||||
/// language applied to compact bordered chips.
|
||||
class _ChoiceChips<T> extends StatelessWidget {
|
||||
const _ChoiceChips({
|
||||
required this.label,
|
||||
required this.values,
|
||||
required this.selected,
|
||||
required this.labelFor,
|
||||
required this.onSelect,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final List<T> values;
|
||||
final T selected;
|
||||
final String Function(T) labelFor;
|
||||
final ValueChanged<T> onSelect;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final accent = Theme.of(context).colorScheme.primary;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(label, style: const TextStyle(color: RatuneColors.foreground)),
|
||||
const SizedBox(height: RatuneSpacing.sm),
|
||||
Wrap(
|
||||
spacing: RatuneSpacing.sm,
|
||||
runSpacing: RatuneSpacing.sm,
|
||||
children: [
|
||||
for (final v in values)
|
||||
_Chip(
|
||||
text: labelFor(v),
|
||||
active: v == selected,
|
||||
accent: accent,
|
||||
onTap: () => onSelect(v),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Chip extends StatelessWidget {
|
||||
const _Chip({
|
||||
required this.text,
|
||||
required this.active,
|
||||
required this.accent,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final bool active;
|
||||
final Color accent;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(minHeight: RatuneSpacing.minTouchTarget),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: RatuneSpacing.lg,
|
||||
vertical: RatuneSpacing.md,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: active ? accent : RatuneColors.border,
|
||||
),
|
||||
color: active ? accent.withValues(alpha: 0.12) : RatuneColors.surface,
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: active ? accent : RatuneColors.foreground,
|
||||
fontWeight: active ? FontWeight.w700 : FontWeight.w400,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue