Add settings page
This commit is contained in:
59
lib/ui/pages/settings.dart
Normal file
59
lib/ui/pages/settings.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.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("Color Scheme"),
|
||||
subtitle: switch (state.settings.colorScheme) {
|
||||
ColorSchemeSettings.dark => Text("Dark"),
|
||||
ColorSchemeSettings.light => Text("Light"),
|
||||
ColorSchemeSettings.system => Text("System"),
|
||||
},
|
||||
onTap: () async {
|
||||
final colorScheme = await showDialogOrModal(
|
||||
context: context,
|
||||
builder:
|
||||
(context) => ListView(
|
||||
shrinkWrap: true,
|
||||
children:
|
||||
ColorSchemeSettings.values
|
||||
.map(
|
||||
(s) => ListTile(
|
||||
title: Text(switch (s) {
|
||||
ColorSchemeSettings.dark => "Dark",
|
||||
ColorSchemeSettings.light => "Light",
|
||||
ColorSchemeSettings.system => "System",
|
||||
}),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop(s);
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
if (colorScheme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
await GetIt.I.get<SettingsCubit>().setSettings(
|
||||
state.settings.copyWith(colorScheme: colorScheme),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user