Add theme switcher

This commit is contained in:
Ricardo Markiewicz
2020-01-21 12:44:09 -03:00
parent a05d2a8f48
commit d181afb606
21 changed files with 697 additions and 295 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
import 'dart:io';
import 'package:como_gasto/category_selection_widget.dart';
import 'package:como_gasto/others/category_selection_widget.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:image_picker/image_picker.dart';
@@ -292,7 +292,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
buttonWidth * (1 - _buttonAnimation.value)),
color: Colors.blueAccent,
color: Theme.of(context).floatingActionButtonTheme.backgroundColor ?? Theme.of(context).primaryColor,
),
child: MaterialButton(
onPressed: () {},
@@ -314,7 +314,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
right: 0,
child: Builder(builder: (BuildContext context) {
return Container(
decoration: BoxDecoration(color: Colors.blueAccent),
decoration: BoxDecoration(color: Theme.of(context).floatingActionButtonTheme.backgroundColor ?? Theme.of(context).primaryColor),
child: MaterialButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
+5 -4
View File
@@ -1,5 +1,5 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:como_gasto/month_widget.dart';
import 'package:como_gasto/others/month_widget.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
@@ -7,7 +7,7 @@ import 'package:rect_getter/rect_getter.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import '../expenses_repository.dart';
import '../login_state.dart';
import '../states/login_state.dart';
import '../utils.dart';
class HomePage extends StatefulWidget {
@@ -73,8 +73,9 @@ class _HomePageState extends State<HomePage> {
}),
SizedBox(width: 48.0),
_bottomAction(FontAwesomeIcons.wallet, () {}),
_bottomAction(FontAwesomeIcons.signOutAlt, () {
Provider.of<LoginState>(context).logout();
_bottomAction(Icons.settings, () {
Navigator.pushNamed(context, '/settings');
}),
],
),
+30 -6
View File
@@ -1,9 +1,10 @@
import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import '../login_state.dart';
import '../states/login_state.dart';
class LoginPage extends StatefulWidget {
@override
@@ -54,11 +55,34 @@ class _LoginPageState extends State<LoginPage> {
return child;
}
},
child: RaisedButton(
child: Text("Sign in with Google"),
onPressed: () {
Provider.of<LoginState>(context).login();
},
child: Container(
width: 200,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FloatingActionButton(
backgroundColor: Color(0xff4285F4),
child: Icon(FontAwesomeIcons.google),
onPressed: () {
Provider.of<LoginState>(context).login(LoginProvider.GOOGLE);
},
),
FloatingActionButton(
backgroundColor: Color(0xff00aced),
child: Icon(FontAwesomeIcons.twitter),
onPressed: () {
Provider.of<LoginState>(context).login(LoginProvider.TWITTER);
},
),
FloatingActionButton(
backgroundColor: Color(0xff3b5998),
child: Icon(FontAwesomeIcons.facebook),
onPressed: () {
Provider.of<LoginState>(context).login(LoginProvider.FACEBOOK);
},
),
],
),
),
),
Expanded(
+52
View File
@@ -0,0 +1,52 @@
import 'package:como_gasto/states/theme_state.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class SettingsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Settings"),
),
body: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Consumer<ThemeState>(
builder: (context, state, child) {
return Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: Text("Use Dark mode?"),
),
Switch(
value: state.isDarkModeEnabled,
onChanged: (_) {
state.setDarkMode(!state.isDarkModeEnabled);
},
),
],
);
},
),
Expanded(
child: Container(),
),
Container(
width: double.infinity,
child: RaisedButton(
onPressed: () {
//Provider.of<LoginState>(context).logout();
},
child: Text("Sign Out"),
),
)
],
),
),
);
}
}