Skip to content

Commit

Permalink
Merge pull request #17 from RedCommander735/develop
Browse files Browse the repository at this point in the history
Feature: Settings menu
  • Loading branch information
RedCommander735 authored May 20, 2024
2 parents 78b632c + 30bc8c3 commit 438e097
Show file tree
Hide file tree
Showing 43 changed files with 1,365 additions and 315 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ name: Build
on:
push:
branches:
- '*'
- 'main'
- 'develop'
tags:
- '*'
pull_request:
branches:
- 'develop'

workflow_dispatch:

Expand Down Expand Up @@ -47,7 +51,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: "12.x"
java-version: "17.x"
cache: 'gradle'

- uses: subosito/flutter-action@v2
Expand Down
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,11 @@ Also add information on how to contact you by electronic and paper mail.
notice like this when it starts in an interactive mode:

Spritverbrauch Copyright (C) 2024 RedCommander735
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w`.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
under certain conditions; type `show c` for details.

The hypothetical commands `show w' and `show c' should show the appropriate
The hypothetical commands `show w` and `show c` should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ A simple app to keep track of how much fuel you're using on average.
- [x] Database and backend stuff (actual function)
- [x] Prices with 3rd digit ^
- [x] Time date selector for overview
- [ ] Settings page via breadcrumbs
- [ ] App info
- [ ] Backup to csv/xslx/...?
- [x] Settings page via breadcrumbs

#### Extra stuff:
- [ ] Edit Items on longpress instead of deleting
Expand All @@ -26,4 +24,6 @@ A simple app to keep track of how much fuel you're using on average.
- [ ] Time date selector for overview
- [ ] Add option set starting date from listview item
- [ ] Settings page via breadcrumbs
- [ ] File explorer for csv import
- [ ] Option to only load elements and do not delete old
- [ ] Color Theme changer
1 change: 0 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "de.redcommander735.spritverbrauch"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<application
android:label="Spritverbrauch${applicationLabelSuffix}"
android:name="${applicationName}"
Expand Down
32 changes: 30 additions & 2 deletions changelogs/CHANGELOG - latest.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
## Changelog:
- Hotfix: Text color was always set to black
- All prices had some rounding errors. Thats fixed now
- Adjusted background color for dark mode
- New settings menu
- General
- Backup
- About


## Technical changes:
- fix: text color was set to black
- feat: new custom number formatter
- fix: all numbers should now display correctly
- feat: new settings icon in main menu
- style: adjusted 'filter active' text
- style: dark mode background now fully black
- style: centered page titles
- ci: new dependency to read app version
- feat: first enty on about page in settings
- chore: bump version number
- feat: add settings group and license info
- fix: typo in license
- chore: removed cuppertino_icons and added url_launcher and fontawesome 5 brands
- feat: add fontawesome 5 brands
- fix: add all applicable licenses
- feat: finished about page in settings
- refactor: move all settings components to their own file
- chore: format all documents
- feat: added general settings page
- style: changed all icons to their rounded variants
- style: added spacing below group headline
- chore: add csv and storage perm handler
- feat: new deleteAll and createItems methods
- feat: csv ex and import
- feat: confirmation dialog to prevent accidental loads
34 changes: 34 additions & 0 deletions fonts/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Font Awesome Free License
-------------------------

Font Awesome Free is free, open source, and GPL friendly. You can use it for
commercial projects, open source projects, or really almost whatever you want.
Full Font Awesome Free license: https://fontawesome.com/license/free.

# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
In the Font Awesome Free download, the CC BY 4.0 license applies to all icons
packaged as SVG and JS file types.

# Fonts: SIL OFL 1.1 License (https://scripts.sil.org/OFL)
In the Font Awesome Free download, the SIL OFL license applies to all icons
packaged as web and desktop font files.

# Code: MIT License (https://opensource.org/licenses/MIT)
In the Font Awesome Free download, the MIT license applies to all non-font and
non-icon files.

# Attribution
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
Awesome Free files already contain embedded comments with sufficient
attribution, so you shouldn't need to do anything additional when using these
files normally.

We've kept attribution comments terse, so we ask that you do not actively work
to remove them from files, especially code. They're a great way for folks to
learn about Font Awesome.

# Brand Icons
All brand icons are trademarks of their respective owners. The use of these
trademarks does not indicate endorsement of the trademark holder by Font
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
to represent the company, product, or service to which they refer.**
Binary file added fonts/otfs/Font-Awesome-5-Brands-Regular-400.otf
Binary file not shown.
Binary file added fonts/otfs/Font-Awesome-5-Free-Regular-400.otf
Binary file not shown.
Binary file added fonts/otfs/Font-Awesome-5-Free-Solid-900.otf
Binary file not shown.
19 changes: 19 additions & 0 deletions fonts/otfs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
A HEADS UP ABOUT DUOTONE ICONS ON THE DESKTOP
---------------------------------------------

Duotone icons are a bit different to use than other Font Awesome icons at the moment.

* We currently recommend using the Duotone-specific optimized .svg vector
files. These can be found in the /svgs/duotone folder of this download.

* Using Ligatures with Duotone Icons is NOT currently recommended - while we've
included a Duotone ligature-based font file in our Pro desktop download, we
can't recommend it as a way to use our icons on the desktop. Read the special
instructions for using duotones with ligatures here -
https://fontawesome.com/how-to-use/on-the-desktop/referencing-icons/duotone-icons#using-ligatures.

You can read the nitty gritty on the current limitations desktop apps have that
made our Duotone ligature implementation diferent there as well. And our full
Duotone Desktop docs are available at:

https://fontawesome.com/how-to-use/on-the-desktop/referencing-icons/duotone-icons.
91 changes: 56 additions & 35 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,40 @@ import 'package:dynamic_color/dynamic_color.dart';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:spritverbrauch/src/filter/filter_model.dart';
import 'package:spritverbrauch/src/settings/filter_model.dart';

import 'package:spritverbrauch/src/listview/item_list_model.dart';
import 'package:spritverbrauch/src/listview/item_list_view.dart';
import 'package:spritverbrauch/src/overview.dart';
import 'package:spritverbrauch/src/add_item.dart';
import 'package:spritverbrauch/src/filter/filter.dart';
import 'package:spritverbrauch/src/settings/filter.dart';

import 'package:provider/provider.dart';
import 'package:spritverbrauch/src/settings/settings.dart';
import 'package:spritverbrauch/src/settings/settings_model.dart';
import 'package:spritverbrauch/src/utils/licenses.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
addLicenses();

runApp(
MultiProvider(providers: [
ChangeNotifierProvider(create: (BuildContext context) => ItemListModel()),
ChangeNotifierProvider(create: (BuildContext context) => FilterModel())
ChangeNotifierProvider(create: (BuildContext context) => FilterModel()),
ChangeNotifierProvider(create: (BuildContext context) => SettingsModel()),
], child: const Spritpreise()),
);
}

class Spritpreise extends StatefulWidget {
const Spritpreise({super.key});

static final _defaultLightColorScheme = ColorScheme.fromSeed(
seedColor: Colors.blue[900]!, brightness: Brightness.light);
static final _defaultLightColorScheme =
ColorScheme.fromSeed(seedColor: Colors.blue[900]!, brightness: Brightness.light);

static final _defaultDarkColorScheme = ColorScheme.fromSeed(
seedColor: Colors.blue[900]!, brightness: Brightness.dark);
static final _defaultDarkColorScheme =
ColorScheme.fromSeed(seedColor: Colors.blue[900]!, brightness: Brightness.dark, background: Colors.black);

@override
State<Spritpreise> createState() => _SpritpreiseState();
Expand Down Expand Up @@ -61,10 +66,13 @@ class _SpritpreiseState extends State<Spritpreise> {
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: lightColorScheme ?? Spritpreise._defaultLightColorScheme,
scaffoldBackgroundColor: Spritpreise._defaultLightColorScheme.background,
useMaterial3: true,
),
darkTheme: ThemeData(
colorScheme: darkColorScheme ?? Spritpreise._defaultDarkColorScheme,
appBarTheme: AppBarTheme(backgroundColor: Spritpreise._defaultDarkColorScheme.background),
scaffoldBackgroundColor: Spritpreise._defaultDarkColorScheme.background,
useMaterial3: true,
),
themeMode: ThemeMode.system,
Expand Down Expand Up @@ -118,38 +126,51 @@ class Main extends StatelessWidget {
Padding(
padding: const EdgeInsets.all(8.0),
child: Consumer2<FilterModel, ItemListModel>(
builder: (BuildContext context, FilterModel filterModel,
ItemListModel itemListModel, Widget? child) {
return Row(
builder: (BuildContext context, FilterModel filterModel, ItemListModel itemListModel,
Widget? child) {
return Column(
children: [
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Filter(),
),
);
},
icon: const Icon(Icons.tune),
),
if (filterModel.filterEnabled)
const Text(
'Filter aktiv',
style: TextStyle(fontSize: 14),
),
if (filterModel.filterEnabled && itemListModel.hiddenEntries > 0)
Text(
', ausgeblendete Enträge: ${itemListModel.hiddenEntries}',
style: const TextStyle(fontSize: 14),
Row(children: [
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Settings(),
),
);
},
icon: const Icon(Icons.settings),
),
if (filterModel.filterEnabled)
IconButton(
onPressed: () {
filterModel.setFilterEnabled(false);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Filter(),
),
);
},
icon: const Icon(Icons.close),
)
icon: const Icon(Icons.tune),
),
if (filterModel.filterEnabled)
const Text(
'Filter aktiv',
style: TextStyle(fontSize: 14),
),
if (filterModel.filterEnabled && itemListModel.hiddenEntries > 0)
Text(
', ausgeblendet: ${itemListModel.hiddenEntries}',
style: const TextStyle(fontSize: 14),
),
if (filterModel.filterEnabled)
IconButton(
onPressed: () {
filterModel.setFilterEnabled(false);
},
icon: const Icon(Icons.close),
),
]),
],
);
},
Expand All @@ -164,7 +185,7 @@ class Main extends StatelessWidget {
),
Center(
child: Padding(
padding: EdgeInsets.symmetric(vertical: 80),
padding: EdgeInsets.only(top: 80),
child: FractionallySizedBox(
widthFactor: 0.55,
child: Overview(),
Expand Down
14 changes: 7 additions & 7 deletions lib/src/add_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class _AddItemState extends State<AddItem> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Eintrag hinzufügen')),
appBar: AppBar(
title: const Text('Eintrag hinzufügen'),
centerTitle: true,
),
body: Form(
key: _formKey,
child: Scrollbar(
Expand All @@ -52,11 +55,9 @@ class _AddItemState extends State<AddItem> {
filled: true,
labelText: 'Datum',
prefixIcon: const Icon(Icons.calendar_today),
enabledBorder:
const OutlineInputBorder(borderSide: BorderSide.none),
enabledBorder: const OutlineInputBorder(borderSide: BorderSide.none),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary),
borderSide: BorderSide(color: Theme.of(context).colorScheme.primary),
),
),
readOnly: true,
Expand Down Expand Up @@ -153,8 +154,7 @@ class _AddItemState extends State<AddItem> {
litersPerKilometer: litersPerKilometer,
);

Provider.of<ItemListModel>(context, listen: false)
.add(item);
Provider.of<ItemListModel>(context, listen: false).add(item);

ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("Eintrag hinzugefügt"),
Expand Down
9 changes: 9 additions & 0 deletions lib/src/components/font_awesome.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:flutter/widgets.dart';

class FontAwesomeBrands {
FontAwesomeBrands._();

static const _kFontFam = 'FontAwesomeBrands';

static const IconData github = IconData(0xf09b, fontFamily: _kFontFam);
}
33 changes: 33 additions & 0 deletions lib/src/components/settings/settings_group.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';

class SettingsGroup extends StatelessWidget {
const SettingsGroup({super.key, required this.title, required this.children});

final String title;
final List<Widget> children;

@override
Widget build(BuildContext context) {
return Column(
children: List.from([
Row(
children: [
Padding(
padding: const EdgeInsets.only(left: 16, top: 16, bottom: 4),
child: Text(
title,
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontWeight: FontWeight.bold,
fontSize: DefaultTextStyle.of(context).style.fontSize! * 17 / 20),
),
),
],
)
])
..addAll(children)..add(const Divider(
height: 0,
)),
);
}
}
Loading

0 comments on commit 438e097

Please sign in to comment.