mirror of
https://github.com/go-vikunja/app
synced 2024-06-05 03:59:48 +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 'dart:io';
|
||||||
|
|
||||||
|
import 'package:dynamic_color/dynamic_color.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
@ -96,12 +97,16 @@ class VikunjaApp extends StatelessWidget {
|
||||||
|
|
||||||
return new ValueListenableBuilder(valueListenable: updateTheme, builder: (_,mode,__) {
|
return new ValueListenableBuilder(valueListenable: updateTheme, builder: (_,mode,__) {
|
||||||
updateTheme.value = false;
|
updateTheme.value = false;
|
||||||
|
FlutterThemeMode themeMode = FlutterThemeMode.system;
|
||||||
Future<ThemeData> theme = manager.getThemeMode().then((value) {
|
Future<ThemeData> theme = manager.getThemeMode().then((value) {
|
||||||
|
themeMode = value;
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case FlutterThemeMode.dark:
|
case FlutterThemeMode.dark:
|
||||||
return buildVikunjaDarkTheme();
|
return buildVikunjaDarkTheme();
|
||||||
case FlutterThemeMode.materialUi:
|
case FlutterThemeMode.materialYouLight:
|
||||||
return buildVikunjaMaterialTheme();
|
return buildVikunjaMaterialLightTheme();
|
||||||
|
case FlutterThemeMode.materialYouDark:
|
||||||
|
return buildVikunjaMaterialDarkTheme();
|
||||||
default:
|
default:
|
||||||
return buildVikunjaTheme();
|
return buildVikunjaTheme();
|
||||||
}
|
}
|
||||||
|
@ -111,14 +116,22 @@ class VikunjaApp extends StatelessWidget {
|
||||||
future: theme,
|
future: theme,
|
||||||
builder: (BuildContext context, AsyncSnapshot<ThemeData> data) {
|
builder: (BuildContext context, AsyncSnapshot<ThemeData> data) {
|
||||||
if(data.hasData) {
|
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',
|
title: 'Vikunja',
|
||||||
theme: data.data,
|
theme: themeData,
|
||||||
scaffoldMessengerKey: globalSnackbarKey,
|
scaffoldMessengerKey: globalSnackbarKey,
|
||||||
navigatorKey: navkey,
|
navigatorKey: navkey,
|
||||||
// <= this
|
// <= this
|
||||||
home: this.home,
|
home: this.home,
|
||||||
);
|
);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return Center(child: CircularProgressIndicator());
|
return Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ class _ListPageState extends State<ListPage> {
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
case PageStatus.success:
|
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(
|
? ListenableProvider.value(
|
||||||
value: taskState,
|
value: taskState,
|
||||||
child: Theme(
|
child: Theme(
|
||||||
|
@ -182,6 +182,7 @@ class _ListPageState extends State<ListPage> {
|
||||||
Widget buildSubProjectSelector() {
|
Widget buildSubProjectSelector() {
|
||||||
return Container(
|
return Container(
|
||||||
height: 80,
|
height: 80,
|
||||||
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||||
child:
|
child:
|
||||||
ListView(
|
ListView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
|
@ -213,42 +214,43 @@ class _ListPageState extends State<ListPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _listView(BuildContext context) {
|
Widget _listView(BuildContext context) {
|
||||||
List<Widget> subProjectView = [];
|
List<Widget> children = [];
|
||||||
if(widget.project.subprojects?.length != 0) {
|
if(widget.project.subprojects?.length != 0) {
|
||||||
subProjectView.add(Padding(child: Text("Projects", style: TextStyle(fontWeight: FontWeight.bold),), padding: EdgeInsets.fromLTRB(0, 10, 0, 0),));
|
children.add(Padding(child: Text("Projects", style: TextStyle(fontWeight: FontWeight.bold),), padding: EdgeInsets.fromLTRB(0, 10, 0, 0),));
|
||||||
subProjectView.add(buildSubProjectSelector());
|
children.add(buildSubProjectSelector());
|
||||||
subProjectView.add(Padding(child: Text("Tasks", style: TextStyle(fontWeight: FontWeight.bold),), padding: EdgeInsets.fromLTRB(0, 10, 0, 0),));
|
|
||||||
subProjectView.add(Divider());
|
}
|
||||||
|
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(
|
return Column(children: children);
|
||||||
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]);
|
|
||||||
}))]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTile(Task task) {
|
Widget _buildTile(Task task) {
|
||||||
|
|
|
@ -130,8 +130,12 @@ class SettingsPageState extends State<SettingsPage> {
|
||||||
value: FlutterThemeMode.dark,
|
value: FlutterThemeMode.dark,
|
||||||
),
|
),
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
child: Text("Material You"),
|
child: Text("Material You Light"),
|
||||||
value: FlutterThemeMode.materialUi,
|
value: FlutterThemeMode.materialYouLight,
|
||||||
|
),
|
||||||
|
DropdownMenuItem(
|
||||||
|
child: Text("Material You Dark"),
|
||||||
|
value: FlutterThemeMode.materialYouDark,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
value: themeMode,
|
value: themeMode,
|
||||||
|
|
|
@ -320,6 +320,10 @@ class SettingsManager {
|
||||||
return FlutterThemeMode.light;
|
return FlutterThemeMode.light;
|
||||||
case "dark":
|
case "dark":
|
||||||
return FlutterThemeMode.dark;
|
return FlutterThemeMode.dark;
|
||||||
|
case "materialYouLight":
|
||||||
|
return FlutterThemeMode.materialYouLight;
|
||||||
|
case "materialYouDark":
|
||||||
|
return FlutterThemeMode.materialYouDark;
|
||||||
default:
|
default:
|
||||||
return FlutterThemeMode.system;
|
return FlutterThemeMode.system;
|
||||||
}
|
}
|
||||||
|
@ -335,5 +339,6 @@ enum FlutterThemeMode {
|
||||||
system,
|
system,
|
||||||
light,
|
light,
|
||||||
dark,
|
dark,
|
||||||
materialUi
|
materialYouLight,
|
||||||
|
materialYouDark,
|
||||||
}
|
}
|
|
@ -17,6 +17,7 @@ class FancyButton extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return ElevatedButton(onPressed: onPressed, child: child);
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: vStandardVerticalPadding,
|
padding: vStandardVerticalPadding,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -33,7 +34,7 @@ class FancyButton extends StatelessWidget {
|
||||||
]),
|
]),
|
||||||
child: Material(
|
child: Material(
|
||||||
borderRadius: BorderRadius.circular(3),
|
borderRadius: BorderRadius.circular(3),
|
||||||
color: vButtonColor,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onPressed,
|
onTap: onPressed,
|
||||||
child: Center(
|
child: Center(
|
||||||
|
|
|
@ -11,9 +11,10 @@ class VikunjaButtonText extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return Text(text);
|
||||||
return Text(
|
return Text(
|
||||||
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 buildVikunjaTheme() => _buildVikunjaTheme(ThemeData.light());
|
||||||
ThemeData buildVikunjaDarkTheme() => _buildVikunjaTheme(ThemeData.dark(), isDark: true);
|
ThemeData buildVikunjaDarkTheme() => _buildVikunjaTheme(ThemeData.dark(), isDark: true);
|
||||||
|
|
||||||
ThemeData buildVikunjaMaterialTheme() {
|
ThemeData buildVikunjaMaterialLightTheme() {
|
||||||
return _buildVikunjaTheme(ThemeData.light()).copyWith(
|
return ThemeData.light().copyWith(
|
||||||
|
useMaterial3: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
ThemeData buildVikunjaMaterialDarkTheme() {
|
||||||
|
return ThemeData.dark().copyWith(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
10
pubspec.lock
10
pubspec.lock
|
@ -177,6 +177,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0+3"
|
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:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -1023,4 +1031,4 @@ packages:
|
||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.0.0-0 <4.0.0"
|
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
|
url_launcher: ^6.1.7
|
||||||
workmanager: ^0.5.1
|
workmanager: ^0.5.1
|
||||||
permission_handler: ^10.2.0
|
permission_handler: ^10.2.0
|
||||||
|
dynamic_color: ^1.6.6
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user