5 Commits

Author SHA1 Message Date
d51f3d4ba7 Merge pull request 'Data import and export' (#6) from development into main
All checks were successful
Flutter APK Build / Build Flutter APK (push) Successful in 7m54s
Reviewed-on: #6
2026-01-22 18:47:02 +01:00
06a76afc42 Merge pull request 'Theme changes' (#4) from development into main
All checks were successful
Flutter APK Build / Build Flutter APK (push) Successful in 6m46s
Reviewed-on: #4
2026-01-21 16:38:03 +01:00
dca8c64555 Merge pull request 'small theme changes' (#3) from development into main
All checks were successful
Flutter APK Build / Build Flutter APK (push) Successful in 6m48s
Reviewed-on: #3
2026-01-21 15:05:11 +01:00
1aaea5f6d9 Merge pull request '[fix] Added basic locatlization' (#2) from development into main
All checks were successful
Flutter APK Build / Calculate Version (push) Successful in 13s
Flutter APK Build / Build Flutter APK (push) Successful in 6m34s
Flutter APK Build / Create Release (push) Has been skipped
Reviewed-on: #2
2026-01-21 14:12:41 +01:00
3a54a077f3 Merge pull request '[fix] added bookmark count number to collections page' (#1) from development into main
All checks were successful
Flutter APK Build / Calculate Version (push) Successful in 15s
Flutter APK Build / Build Flutter APK (push) Successful in 6m37s
Flutter APK Build / Create Release (push) Has been skipped
Reviewed-on: #1
2026-01-21 13:20:49 +01:00
5 changed files with 39 additions and 72 deletions

View File

@@ -4,6 +4,9 @@ on:
push: push:
branches: branches:
- main - main
pull_request:
branches:
- main
workflow_dispatch: workflow_dispatch:

View File

@@ -17,90 +17,55 @@ class SettingsPage extends StatefulWidget {
} }
class _SettingsPageState extends State<SettingsPage> { class _SettingsPageState extends State<SettingsPage> {
bool storagePermissionIsGranted = false;
final tileSpacing = 16.0;
@override
void initState() {
PermissionService.storagePermissionStatus.then((value) {
storagePermissionIsGranted = value.isGranted;
if (context.mounted) setState(() {});
});
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final titlePadding = Theme.of(context).listTileTheme.contentPadding!;
checkStoragePermission();
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(AppLocalizations.of(context)!.settings)), appBar: AppBar(title: Text(AppLocalizations.of(context)!.settings)),
body: Center( body: SizedBox(
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9, width: MediaQuery.of(context).size.width * 0.9,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Padding( Text(
padding: titlePadding,
child: Text(
AppLocalizations.of(context)!.appData, AppLocalizations.of(context)!.appData,
style: Theme.of(context).textTheme.titleLarge, style: Theme.of(context).textTheme.titleLarge,
), ),
ElevatedButton(
onPressed: () => onActivateJsonImportPressed(),
child: Text(AppLocalizations.of(context)!.import),
), ),
SizedBox(height: tileSpacing), ElevatedButton(
ListTile( onPressed: () => onActivateJsonExportPressed(),
title: Text('Grant storage permisson'), child: Text(AppLocalizations.of(context)!.export),
subtitle: Text(
'For app-data settings to work, you need to grant the app permissions to manage internal storage.',
),
onTap: () => PermissionService.requestStoragePermission
.whenComplete(() => checkStoragePermission()),
trailing: Icon(Icons.arrow_forward_ios_rounded),
enabled: !storagePermissionIsGranted,
),
SizedBox(height: tileSpacing),
ListTile(
title: Text(AppLocalizations.of(context)!.import),
subtitle: Text('Import app-data from a json file.'),
onTap: () => onActivateJsonImportPressed(),
trailing: Icon(Icons.arrow_forward_ios_rounded),
enabled: storagePermissionIsGranted,
),
SizedBox(height: tileSpacing),
ListTile(
title: Text(AppLocalizations.of(context)!.export),
subtitle: Text(
'Export app-data to a json file in the selected directory.',
),
onTap: () => onActivateJsonExportPressed(),
trailing: Icon(Icons.arrow_forward_ios_rounded),
enabled: storagePermissionIsGranted,
), ),
], ],
), ),
), ),
),
); );
} }
void onActivateJsonExportPressed() async { void onActivateJsonExportPressed() async {
if (!await PermissionService.storagePermissionStatus.isGranted) return; if (!await checkStoragePermission) return;
Storage.exportToJsonFile().then(showExportInfo); Storage.exportToJsonFile().then(showExportInfo);
} }
void onActivateJsonImportPressed() async { void onActivateJsonImportPressed() async {
if (!await PermissionService.storagePermissionStatus.isGranted) return; if (!await checkStoragePermission) return;
Storage.importFromJsonFile().then(showImportInfo); Storage.importFromJsonFile().then(showImportInfo);
} }
Future<void> checkStoragePermission() async { Future<bool> get checkStoragePermission async {
PermissionService.storagePermissionStatus.then((value) { if (!(await PermissionService.requestStoragePermission).isGranted) {
storagePermissionIsGranted = value.isGranted; if (mounted) {
if (context.mounted && value.isGranted != storagePermissionIsGranted) { Notifying.showErrorSnackbar(
setState(() {}); context,
AppLocalizations.of(context)!.errorStoragePermisson,
);
return false;
} }
}); }
return true;
} }
void showExportInfo(bool success) => Notifying.showSnackbar( void showExportInfo(bool success) => Notifying.showSnackbar(
@@ -108,7 +73,7 @@ class _SettingsPageState extends State<SettingsPage> {
text: success text: success
? AppLocalizations.of(context)!.exportSuccess ? AppLocalizations.of(context)!.exportSuccess
: AppLocalizations.of(context)!.exportFailed, : AppLocalizations.of(context)!.exportFailed,
isError: !success, isError: success,
); );
void showImportInfo(bool success) => Notifying.showSnackbar( void showImportInfo(bool success) => Notifying.showSnackbar(
@@ -116,6 +81,6 @@ class _SettingsPageState extends State<SettingsPage> {
text: success text: success
? AppLocalizations.of(context)!.importSuccess ? AppLocalizations.of(context)!.importSuccess
: AppLocalizations.of(context)!.importFailed, : AppLocalizations.of(context)!.importFailed,
isError: !success, isError: success,
); );
} }

View File

@@ -32,7 +32,7 @@ class JsonFileService {
} catch (e) { } catch (e) {
return false; return false;
} }
return true; return false;
} }
static Future<({List<Collection> collections, List<Bookmark> bookmarks})> static Future<({List<Collection> collections, List<Bookmark> bookmarks})>

View File

@@ -12,7 +12,7 @@ class Notifying {
ScaffoldMessenger.of(context).hideCurrentSnackBar(); ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
backgroundColor: isError ? Theme.of(context).colorScheme.error : null, backgroundColor: Theme.of(context).colorScheme.error,
content: SizedBox( content: SizedBox(
height: 30, height: 30,
child: Row( child: Row(
@@ -29,7 +29,7 @@ class Notifying {
ScaffoldMessenger.of(context).hideCurrentSnackBar(), ScaffoldMessenger.of(context).hideCurrentSnackBar(),
icon: Icon( icon: Icon(
Icons.close_rounded, Icons.close_rounded,
color: isError ? Theme.of(context).colorScheme.onError : null, color: Theme.of(context).colorScheme.onError,
), ),
), ),
], ],

View File

@@ -22,6 +22,5 @@ ThemeData _baseTheme(ColorScheme scheme) =>
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadiusGeometry.circular(12), borderRadius: BorderRadiusGeometry.circular(12),
), ),
contentPadding: EdgeInsetsDirectional.only(start: 16.0, end: 24.0),
), ),
); );