74 lines
2.9 KiB
Dart
74 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:okane/i18n/strings.g.dart';
|
|
import 'package:okane/ui/state/settings.dart';
|
|
import 'package:okane/ui/utils.dart';
|
|
|
|
class SettingsPage extends StatelessWidget {
|
|
const SettingsPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView(
|
|
children: [
|
|
BlocBuilder<SettingsCubit, SettingsWrapper>(
|
|
builder:
|
|
(context, state) => ListTile(
|
|
title: Text(t.pages.settings.colorSchemes.title),
|
|
subtitle: switch (state.settings.colorScheme) {
|
|
ColorSchemeSettings.dark => Text(
|
|
t.pages.settings.colorSchemes.dark,
|
|
),
|
|
ColorSchemeSettings.light => Text(
|
|
t.pages.settings.colorSchemes.light,
|
|
),
|
|
ColorSchemeSettings.system => Text(
|
|
t.pages.settings.colorSchemes.system,
|
|
),
|
|
},
|
|
onTap: () async {
|
|
final colorScheme = await showDialogOrModal(
|
|
context: context,
|
|
builder:
|
|
(context) => ListView(
|
|
shrinkWrap: true,
|
|
children:
|
|
ColorSchemeSettings.values
|
|
.map(
|
|
(s) => ListTile(
|
|
leading:
|
|
state.settings.colorScheme == s
|
|
? Icon(Icons.check)
|
|
: null,
|
|
title: Text(switch (s) {
|
|
ColorSchemeSettings.dark =>
|
|
t.pages.settings.colorSchemes.dark,
|
|
ColorSchemeSettings.light =>
|
|
t.pages.settings.colorSchemes.light,
|
|
ColorSchemeSettings.system =>
|
|
t.pages.settings.colorSchemes.system,
|
|
}),
|
|
onTap: () {
|
|
Navigator.of(context).pop(s);
|
|
},
|
|
),
|
|
)
|
|
.toList(),
|
|
),
|
|
);
|
|
if (colorScheme == null) {
|
|
return;
|
|
}
|
|
|
|
await GetIt.I.get<SettingsCubit>().setSettings(
|
|
state.settings.copyWith(colorScheme: colorScheme),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|