Add temporary settings screen

This commit is contained in:
Oystein Kristoffer Tveit 2021-08-03 22:04:29 +02:00
parent e8f42860af
commit ff6f6ef868
3 changed files with 76 additions and 2 deletions

View File

@ -15,7 +15,7 @@ import 'package:jisho_study_tool/bloc/navigation/navigation_bloc.dart';
import 'package:jisho_study_tool/view/screens/kanji/view.dart';
import 'package:jisho_study_tool/view/screens/history.dart';
import 'package:jisho_study_tool/view/screens/search/view.dart';
import 'package:jisho_study_tool/view/screens/settings.dart';
void main() => runApp(MyApp());
@ -154,7 +154,7 @@ final List<_Page> pages = [
),
),
_Page(
content: Container(),
content: SettingsView(),
titleBar: Text("Settings"),
item: BottomNavigationBarItem(
label: 'Settings',

View File

@ -0,0 +1,72 @@
import 'package:confirm_dialog/confirm_dialog.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:jisho_study_tool/bloc/database/database_bloc.dart';
import 'package:jisho_study_tool/models/history/search.dart';
import 'package:jisho_study_tool/objectbox.g.dart';
import 'package:settings_ui/settings_ui.dart';
class SettingsView extends StatelessWidget {
Widget build(BuildContext context) {
return SettingsList(
sections: [
SettingsSection(
title: 'Cache',
tiles: [
SettingsTile.switchTile(
title: 'Cache grade 1-7 kanji (N/A)',
switchValue: false,
onToggle: (v) {},
),
SettingsTile.switchTile(
title: 'Cache grade standard kanji (N/A)',
switchValue: false,
onToggle: (v) {},
),
SettingsTile.switchTile(
title: 'Cache all favourites (N/A)',
switchValue: false,
onToggle: (v) {},
),
SettingsTile.switchTile(
title: 'Cache all searches (N/A)',
switchValue: false,
onToggle: (v) {},
),
],
),
SettingsSection(
title: 'Data',
tiles: [
SettingsTile(
leading: Icon(Icons.file_download),
title: 'Export Data (N/A)',
),
SettingsTile(
leading: Icon(Icons.delete),
title: 'Clear History (N/A)',
onPressed: _clearHistory,
titleTextStyle: TextStyle(color: Colors.red),
),
SettingsTile(
leading: Icon(Icons.delete),
title: 'Clear Favourites (N/A)',
onPressed: (c) {},
titleTextStyle: TextStyle(color: Colors.red),
)
],
)
],
);
}
}
void _clearHistory(context) async {
if (await confirm(context)) {
Store db =
(BlocProvider.of<DatabaseBloc>(context).state as DatabaseConnected)
.database;
// db.box<Search>().query().build().find()
db.box<Search>().removeAll();
}
}

View File

@ -7,6 +7,7 @@ environment:
dependencies:
animated_size_and_fade: ^2.0.0
confirm_dialog: ^1.0.0
division: ^0.9.0
flutter:
sdk: flutter
@ -19,6 +20,7 @@ dependencies:
shared_preferences: ^2.0.6
unofficial_jisho_api: ^2.0.2
url_launcher: ^6.0.9
settings_ui: ^1.0.0
dev_dependencies: