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",
"lineChart":"Spojnicový",
"barChart":"Sloupcový",
"selectType":"Zvolte typ",
"enableYou":"Povolit Material You (Může vyžadovat restart aplikace)",
"enableYouDesc":"Aplikace použije barevné schéma z vaší tapety"
"selectType":"Zvolte typ"
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,9 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:prasule/main.dart';
import 'package:prasule/pw/platformroute.dart';
import 'package:prasule/views/settings/graph_type.dart';
import 'package:prasule/views/settings/tessdata_list.dart';
import 'package:settings_ui/settings_ui.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:shared_preferences/shared_preferences.dart';
class SettingsView extends StatefulWidget {
const SettingsView({super.key});
@ -17,17 +13,6 @@ class SettingsView extends StatefulWidget {
}
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
Widget build(BuildContext context) {
return Scaffold(
@ -63,19 +48,7 @@ class _SettingsViewState extends State<SettingsView> {
(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),
)
)
],
)
],