fix: login screen theme

This commit is contained in:
Rongjian Zhang 2020-01-14 18:27:43 +08:00
parent baf3e43045
commit 0b334f341e
3 changed files with 11 additions and 23 deletions

View File

@ -1,34 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:git_touch/home.dart';
import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/theme.dart';
import 'package:provider/provider.dart';
import 'package:git_touch/screens/login.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final auth = Provider.of<AuthModel>(context);
final theme = Provider.of<ThemeModel>(context);
final themData = ThemeData(
brightness: theme.brightness,
// primaryColorBrightness: theme.brightness,
primaryColorLight: theme.paletteLight.background,
primaryColorDark: theme.paletteDark.background,
);
// TODO:
if (!auth.ready || !Provider.of<ThemeModel>(context).ready) {
return MaterialApp(theme: themData, home: Scaffold(body: Text('a')));
}
// Fimber.d(settings.activeLogin);
if (auth.activeAccount == null) {
return MaterialApp(theme: themData, home: LoginScreen());
}
switch (theme.theme) {
case AppThemeType.cupertino:
return CupertinoApp(
@ -37,7 +16,12 @@ class MyApp extends StatelessWidget {
);
default:
return MaterialApp(
theme: themData,
theme: ThemeData(
brightness: theme.brightness,
// primaryColorBrightness: theme.brightness,
primaryColorLight: theme.paletteLight.background,
primaryColorDark: theme.paletteDark.background,
),
home: Home(),
);
}

View File

@ -5,6 +5,7 @@ import 'package:git_touch/models/notification.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/screens/gitlab_todos.dart';
import 'package:git_touch/screens/gitlab_user.dart';
import 'package:git_touch/screens/login.dart';
import 'package:git_touch/screens/notification.dart';
import 'package:git_touch/screens/user.dart';
import 'package:git_touch/utils/utils.dart';
@ -121,6 +122,10 @@ class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
final auth = Provider.of<AuthModel>(context);
if (auth.activeAccount == null) {
return LoginScreen();
}
switch (theme.theme) {
case AppThemeType.cupertino:

View File

@ -31,7 +31,6 @@ class AuthModel with ChangeNotifier {
bool loading = false;
List<Account> get accounts => _accounts;
bool get ready => _accounts != null;
Account get activeAccount {
if (activeAccountIndex == null || _accounts == null) return null;
return _accounts[activeAccountIndex];