mirror of
https://github.com/go-vikunja/app
synced 2024-10-12 08:55:33 +00:00
added material you, changed button style
This commit is contained in:
parent
33242c2bfb
commit
c3a8172739
@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
@ -96,12 +97,16 @@ class VikunjaApp extends StatelessWidget {
|
||||
|
||||
return new ValueListenableBuilder(valueListenable: updateTheme, builder: (_,mode,__) {
|
||||
updateTheme.value = false;
|
||||
FlutterThemeMode themeMode = FlutterThemeMode.system;
|
||||
Future<ThemeData> theme = manager.getThemeMode().then((value) {
|
||||
themeMode = value;
|
||||
switch(value) {
|
||||
case FlutterThemeMode.dark:
|
||||
return buildVikunjaDarkTheme();
|
||||
case FlutterThemeMode.materialUi:
|
||||
return buildVikunjaMaterialTheme();
|
||||
case FlutterThemeMode.materialYouLight:
|
||||
return buildVikunjaMaterialLightTheme();
|
||||
case FlutterThemeMode.materialYouDark:
|
||||
return buildVikunjaMaterialDarkTheme();
|
||||
default:
|
||||
return buildVikunjaTheme();
|
||||
}
|
||||
@ -111,14 +116,22 @@ class VikunjaApp extends StatelessWidget {
|
||||
future: theme,
|
||||
builder: (BuildContext context, AsyncSnapshot<ThemeData> data) {
|
||||
if(data.hasData) {
|
||||
return new MaterialApp(
|
||||
return new DynamicColorBuilder(builder: (lightTheme, darkTheme)
|
||||
{
|
||||
ThemeData? themeData = data.data;
|
||||
if(themeMode == FlutterThemeMode.materialYouLight)
|
||||
themeData = themeData?.copyWith(colorScheme: lightTheme);
|
||||
else if(themeMode == FlutterThemeMode.materialYouDark)
|
||||
themeData = themeData?.copyWith(colorScheme: darkTheme);
|
||||
return MaterialApp(
|
||||
title: 'Vikunja',
|
||||
theme: data.data,
|
||||
theme: themeData,
|
||||
scaffoldMessengerKey: globalSnackbarKey,
|
||||
navigatorKey: navkey,
|
||||
// <= this
|
||||
home: this.home,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class _ListPageState extends State<ListPage> {
|
||||
]);
|
||||
break;
|
||||
case PageStatus.success:
|
||||
body = taskState.tasks.length > 0 || taskState.buckets.length > 0
|
||||
body = taskState.tasks.length > 0 || taskState.buckets.length > 0 || _project.subprojects!.length > 0
|
||||
? ListenableProvider.value(
|
||||
value: taskState,
|
||||
child: Theme(
|
||||
@ -182,6 +182,7 @@ class _ListPageState extends State<ListPage> {
|
||||
Widget buildSubProjectSelector() {
|
||||
return Container(
|
||||
height: 80,
|
||||
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
child:
|
||||
ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
@ -213,42 +214,43 @@ class _ListPageState extends State<ListPage> {
|
||||
}
|
||||
|
||||
Widget _listView(BuildContext context) {
|
||||
List<Widget> subProjectView = [];
|
||||
List<Widget> children = [];
|
||||
if(widget.project.subprojects?.length != 0) {
|
||||
subProjectView.add(Padding(child: Text("Projects", style: TextStyle(fontWeight: FontWeight.bold),), padding: EdgeInsets.fromLTRB(0, 10, 0, 0),));
|
||||
subProjectView.add(buildSubProjectSelector());
|
||||
subProjectView.add(Padding(child: Text("Tasks", style: TextStyle(fontWeight: FontWeight.bold),), padding: EdgeInsets.fromLTRB(0, 10, 0, 0),));
|
||||
subProjectView.add(Divider());
|
||||
children.add(Padding(child: Text("Projects", style: TextStyle(fontWeight: FontWeight.bold),), padding: EdgeInsets.fromLTRB(0, 10, 0, 0),));
|
||||
children.add(buildSubProjectSelector());
|
||||
|
||||
}
|
||||
if(taskState.tasks.length != 0) {
|
||||
children.add(Padding(child: Text("Tasks", style: TextStyle(fontWeight: FontWeight.bold),), padding: EdgeInsets.fromLTRB(0, 10, 0, 0),));
|
||||
children.add(Divider());
|
||||
children.add(Expanded(child:
|
||||
ListView.builder(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
itemCount: taskState.tasks.length * 2,
|
||||
itemBuilder: (context, i) {
|
||||
if (i.isOdd) return Divider();
|
||||
|
||||
if (_loadingTasks.isNotEmpty) {
|
||||
final loadingTask = _loadingTasks.removeLast();
|
||||
return _buildLoadingTile(loadingTask);
|
||||
}
|
||||
|
||||
final index = i ~/ 2;
|
||||
|
||||
if (taskState.maxPages == _currentPage &&
|
||||
index == taskState.tasks.length)
|
||||
throw Exception("Check itemCount attribute");
|
||||
|
||||
if (index >= taskState.tasks.length &&
|
||||
_currentPage < taskState.maxPages) {
|
||||
_currentPage++;
|
||||
_loadTasksForPage(_currentPage);
|
||||
}
|
||||
return _buildTile(taskState.tasks[index]);
|
||||
})));
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
...subProjectView,
|
||||
Expanded(child:
|
||||
ListView.builder(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
itemCount: taskState.tasks.length * 2,
|
||||
itemBuilder: (context, i) {
|
||||
if (i.isOdd) return Divider();
|
||||
|
||||
if (_loadingTasks.isNotEmpty) {
|
||||
final loadingTask = _loadingTasks.removeLast();
|
||||
return _buildLoadingTile(loadingTask);
|
||||
}
|
||||
|
||||
final index = i ~/ 2;
|
||||
|
||||
if (taskState.maxPages == _currentPage &&
|
||||
index == taskState.tasks.length)
|
||||
throw Exception("Check itemCount attribute");
|
||||
|
||||
if (index >= taskState.tasks.length &&
|
||||
_currentPage < taskState.maxPages) {
|
||||
_currentPage++;
|
||||
_loadTasksForPage(_currentPage);
|
||||
}
|
||||
return _buildTile(taskState.tasks[index]);
|
||||
}))]);
|
||||
return Column(children: children);
|
||||
}
|
||||
|
||||
Widget _buildTile(Task task) {
|
||||
|
@ -130,8 +130,12 @@ class SettingsPageState extends State<SettingsPage> {
|
||||
value: FlutterThemeMode.dark,
|
||||
),
|
||||
DropdownMenuItem(
|
||||
child: Text("Material You"),
|
||||
value: FlutterThemeMode.materialUi,
|
||||
child: Text("Material You Light"),
|
||||
value: FlutterThemeMode.materialYouLight,
|
||||
),
|
||||
DropdownMenuItem(
|
||||
child: Text("Material You Dark"),
|
||||
value: FlutterThemeMode.materialYouDark,
|
||||
),
|
||||
],
|
||||
value: themeMode,
|
||||
|
@ -320,6 +320,10 @@ class SettingsManager {
|
||||
return FlutterThemeMode.light;
|
||||
case "dark":
|
||||
return FlutterThemeMode.dark;
|
||||
case "materialYouLight":
|
||||
return FlutterThemeMode.materialYouLight;
|
||||
case "materialYouDark":
|
||||
return FlutterThemeMode.materialYouDark;
|
||||
default:
|
||||
return FlutterThemeMode.system;
|
||||
}
|
||||
@ -335,5 +339,6 @@ enum FlutterThemeMode {
|
||||
system,
|
||||
light,
|
||||
dark,
|
||||
materialUi
|
||||
materialYouLight,
|
||||
materialYouDark,
|
||||
}
|
@ -17,6 +17,7 @@ class FancyButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(onPressed: onPressed, child: child);
|
||||
return Padding(
|
||||
padding: vStandardVerticalPadding,
|
||||
child: Container(
|
||||
@ -33,7 +34,7 @@ class FancyButton extends StatelessWidget {
|
||||
]),
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
color: vButtonColor,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
child: InkWell(
|
||||
onTap: onPressed,
|
||||
child: Center(
|
||||
|
@ -11,9 +11,10 @@ class VikunjaButtonText extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(text);
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(color: vButtonTextColor, fontWeight: FontWeight.w600),
|
||||
style: TextStyle(color: Theme.of(context).primaryTextTheme.labelMedium?.color, fontWeight: FontWeight.w600),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,13 @@ import 'package:vikunja_app/theme/constants.dart';
|
||||
ThemeData buildVikunjaTheme() => _buildVikunjaTheme(ThemeData.light());
|
||||
ThemeData buildVikunjaDarkTheme() => _buildVikunjaTheme(ThemeData.dark(), isDark: true);
|
||||
|
||||
ThemeData buildVikunjaMaterialTheme() {
|
||||
return _buildVikunjaTheme(ThemeData.light()).copyWith(
|
||||
ThemeData buildVikunjaMaterialLightTheme() {
|
||||
return ThemeData.light().copyWith(
|
||||
useMaterial3: true,
|
||||
);
|
||||
}
|
||||
ThemeData buildVikunjaMaterialDarkTheme() {
|
||||
return ThemeData.dark().copyWith(
|
||||
useMaterial3: true,
|
||||
);
|
||||
}
|
||||
|
10
pubspec.lock
10
pubspec.lock
@ -177,6 +177,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0+3"
|
||||
dynamic_color:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dynamic_color
|
||||
sha256: de4798a7069121aee12d5895315680258415de9b00e717723a1bd73d58f0126d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.6.6"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1023,4 +1031,4 @@ packages:
|
||||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.0.0-0 <4.0.0"
|
||||
flutter: ">=3.3.0"
|
||||
flutter: ">=3.4.0-17.0.pre"
|
||||
|
@ -31,6 +31,7 @@ dependencies:
|
||||
url_launcher: ^6.1.7
|
||||
workmanager: ^0.5.1
|
||||
permission_handler: ^10.2.0
|
||||
dynamic_color: ^1.6.6
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
Reference in New Issue
Block a user