Compare commits

..

No commits in common. "057954f6ce3c6c68ab4682059ce2d8dfb12309dd" and "512de4deff1746868bfe657b675baa8fb5dbb8c5" have entirely different histories.

7 changed files with 30 additions and 90 deletions

View file

@ -72,8 +72,6 @@
"graphTypeDesc":"Zvolte, zda-li použít sloupcový, nebo spojnicový graf, a kde", "graphTypeDesc":"Zvolte, zda-li použít sloupcový, nebo spojnicový graf, a kde",
"lineChart":"Spojnicový", "lineChart":"Spojnicový",
"barChart":"Sloupcový", "barChart":"Sloupcový",
"selectType":"Zvolte typ", "selectType":"Zvolte typ"
"enableYou":"Povolit Material You (Může vyžadovat restart aplikace)",
"enableYouDesc":"Aplikace použije barevné schéma z vaší tapety"
} }

View file

@ -152,7 +152,5 @@
"graphTypeDesc":"Choose whether to show line or bar chart and where", "graphTypeDesc":"Choose whether to show line or bar chart and where",
"lineChart":"Line chart", "lineChart":"Line chart",
"barChart":"Bar chart", "barChart":"Bar chart",
"selectType":"Select type", "selectType":"Select type"
"enableYou":"Enable Material You (May require an app restart)",
"enableYouDesc":"The app will use a color scheme from your wallpaper"
} }

View file

@ -8,13 +8,8 @@ import 'package:logger/logger.dart';
import 'package:prasule/util/color_schemes.g.dart'; import 'package:prasule/util/color_schemes.g.dart';
import 'package:prasule/views/home.dart'; import 'package:prasule/views/home.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:shared_preferences/shared_preferences.dart';
var _materialYou = false; void main() {
void main() async {
WidgetsFlutterBinding.ensureInitialized();
var s = await SharedPreferences.getInstance();
_materialYou = s.getBool("useMaterialYou") ?? true;
runApp(const MyApp()); runApp(const MyApp());
} }
@ -22,37 +17,29 @@ final logger = Logger();
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({super.key}); const MyApp({super.key});
static bool appliedYou = false;
// This widget is the root of your application. // This widget is the root of your application.
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return (Platform.isAndroid) return (Platform.isAndroid)
? DynamicColorBuilder( ? DynamicColorBuilder(
builder: (light, dark) { builder: (light, dark) => MaterialApp(
appliedYou = light != null; debugShowCheckedModeBanner: false,
return MaterialApp( localizationsDelegates: const [
debugShowCheckedModeBanner: false, AppLocalizations.delegate,
localizationsDelegates: const [ ...GlobalMaterialLocalizations.delegates,
AppLocalizations.delegate, ...GlobalCupertinoLocalizations.delegates
...GlobalMaterialLocalizations.delegates, ],
...GlobalCupertinoLocalizations.delegates supportedLocales: AppLocalizations.supportedLocales,
], title: 'Prašule',
supportedLocales: AppLocalizations.supportedLocales, theme: ThemeData(
title: 'Prašule', colorScheme: light ?? lightColorScheme,
theme: ThemeData( useMaterial3: true,
colorScheme: (_materialYou) ),
? light ?? lightColorScheme darkTheme: ThemeData(
: lightColorScheme, useMaterial3: true, colorScheme: dark ?? darkColorScheme),
useMaterial3: true, home: const HomeView(),
), ),
darkTheme: ThemeData(
useMaterial3: true,
colorScheme: (_materialYou)
? dark ?? darkColorScheme
: darkColorScheme),
home: const HomeView(),
);
},
) )
: Theme( : Theme(
data: ThemeData( data: ThemeData(

View file

@ -5,16 +5,12 @@ import 'package:prasule/pw/platformwidget.dart';
class PlatformButton extends PlatformWidget<TextButton, CupertinoButton> { class PlatformButton extends PlatformWidget<TextButton, CupertinoButton> {
final String text; final String text;
final void Function()? onPressed; final void Function()? onPressed;
final ButtonStyle? style;
const PlatformButton( const PlatformButton(
{super.key, required this.text, required this.onPressed, this.style}); {super.key, required this.text, required this.onPressed});
@override @override
TextButton createAndroidWidget(BuildContext context) => TextButton( TextButton createAndroidWidget(BuildContext context) =>
onPressed: onPressed, TextButton(onPressed: onPressed, child: Text(text));
style: style,
child: Text(text),
);
@override @override
CupertinoButton createIosWidget(BuildContext context) => CupertinoButton createIosWidget(BuildContext context) =>

View file

@ -1,5 +1,4 @@
import 'package:currency_picker/currency_picker.dart'; import 'package:currency_picker/currency_picker.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:fl_chart/fl_chart.dart'; import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
@ -103,8 +102,7 @@ class ExpensesLineChart extends StatelessWidget {
isStrokeCapRound: true, isStrokeCapRound: true,
dotData: const FlDotData(show: false), dotData: const FlDotData(show: false),
belowBarData: BarAreaData(show: false), belowBarData: BarAreaData(show: false),
color: Colors.green color: Theme.of(context).colorScheme.primary,
.harmonizeWith(Theme.of(context).colorScheme.secondary),
spots: List.generate( spots: List.generate(
(yearly) ? 12 : DateTime(date.year, date.month, 0).day, (yearly) ? 12 : DateTime(date.year, date.month, 0).day,
(index) => FlSpot(index.toDouble(), incomeData[index]), (index) => FlSpot(index.toDouble(), incomeData[index]),
@ -117,8 +115,7 @@ class ExpensesLineChart extends StatelessWidget {
isStrokeCapRound: true, isStrokeCapRound: true,
dotData: const FlDotData(show: false), dotData: const FlDotData(show: false),
belowBarData: BarAreaData(show: false), belowBarData: BarAreaData(show: false),
color: Colors.red color: Theme.of(context).colorScheme.error,
.harmonizeWith(Theme.of(context).colorScheme.secondary),
spots: List.generate( spots: List.generate(
(yearly) ? 12 : DateTime(date.year, date.month, 0).day, (yearly) ? 12 : DateTime(date.year, date.month, 0).day,
(index) => FlSpot(index.toDouble() + 1, expenseData[index]), (index) => FlSpot(index.toDouble() + 1, expenseData[index]),
@ -280,14 +277,12 @@ class ExpensesBarChart extends StatelessWidget {
if (incomeData.isNotEmpty) if (incomeData.isNotEmpty)
BarChartRodData( BarChartRodData(
toY: incomeData[index], toY: incomeData[index],
color: Colors.green color: Theme.of(context).colorScheme.primary,
.harmonizeWith(Theme.of(context).colorScheme.secondary),
), ),
if (expenseData.isNotEmpty) if (expenseData.isNotEmpty)
BarChartRodData( BarChartRodData(
toY: expenseData[index], toY: expenseData[index],
color: Colors.red color: Theme.of(context).colorScheme.error,
.harmonizeWith(Theme.of(context).colorScheme.secondary),
), ),
], ],
), ),

View file

@ -153,7 +153,7 @@ class _GraphViewState extends State<GraphView> {
strokeWidth: 5, strokeWidth: 5,
) )
: SizedBox( : SizedBox(
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -212,13 +212,6 @@ class _GraphViewState extends State<GraphView> {
child: Column( child: Column(
children: [ children: [
PlatformButton( PlatformButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
Theme.of(context).colorScheme.primary),
foregroundColor: MaterialStateProperty.all(
Theme.of(context)
.colorScheme
.onPrimary)),
text: (yearly) text: (yearly)
? DateFormat.y(locale).format(_selectedDate) ? DateFormat.y(locale).format(_selectedDate)
: DateFormat.yMMMM(locale) : DateFormat.yMMMM(locale)

View file

@ -1,13 +1,9 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:prasule/main.dart';
import 'package:prasule/pw/platformroute.dart'; import 'package:prasule/pw/platformroute.dart';
import 'package:prasule/views/settings/graph_type.dart'; import 'package:prasule/views/settings/graph_type.dart';
import 'package:prasule/views/settings/tessdata_list.dart'; import 'package:prasule/views/settings/tessdata_list.dart';
import 'package:settings_ui/settings_ui.dart'; import 'package:settings_ui/settings_ui.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:shared_preferences/shared_preferences.dart';
class SettingsView extends StatefulWidget { class SettingsView extends StatefulWidget {
const SettingsView({super.key}); const SettingsView({super.key});
@ -17,17 +13,6 @@ class SettingsView extends StatefulWidget {
} }
class _SettingsViewState extends State<SettingsView> { class _SettingsViewState extends State<SettingsView> {
var _useMaterialYou = true;
final _supportsYou = MyApp.appliedYou;
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((s) {
_useMaterialYou = s.getBool("useMaterialYou") ?? true;
setState(() {});
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -63,19 +48,7 @@ class _SettingsViewState extends State<SettingsView> {
(p0) => const GraphTypeSettingsView(), (p0) => const GraphTypeSettingsView(),
), ),
), ),
), )
if (Platform.isAndroid && _supportsYou)
SettingsTile.switchTile(
initialValue: _useMaterialYou,
onToggle: (v) async {
var s = await SharedPreferences.getInstance();
s.setBool("useMaterialYou", v);
_useMaterialYou = v;
setState(() {});
},
title: Text(AppLocalizations.of(context).enableYou),
description: Text(AppLocalizations.of(context).enableYouDesc),
)
], ],
) )
], ],