From e9f07c63ef049f9f4a31614e88690337c2e25601 Mon Sep 17 00:00:00 2001 From: denisnadey Date: Mon, 5 Oct 2020 17:18:38 +0300 Subject: [PATCH] after bloc --- .vscode/launch.json | 13 ++++++++++++ lib/main.dart | 6 +++++- lib/route.dart | 52 +++++++++++++++++++++++++++++++++++++++++++++ lib/theme.dart | 6 ++++-- 4 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 lib/route.dart diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..14bdf9e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "cloudtech_calculator", + "request": "launch", + "type": "dart" + } + ] +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 3e8ca5c..875a020 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,7 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:cloudtech_calculator/theme_model.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'route.dart'; enum Operation { plus, @@ -256,7 +257,10 @@ class _MyHomePageState extends State { icon: const Icon(Icons.settings), tooltip: 'Show Snackbar', onPressed: () { - Provider.of(context, listen: false).toggleTheme(); + Navigator.push( + context, + MaterialPageRoute(builder: (context) => SecondRoute()), + ); }, color: Theme.of(context).accentColor, ) diff --git a/lib/route.dart b/lib/route.dart new file mode 100644 index 0000000..41920c5 --- /dev/null +++ b/lib/route.dart @@ -0,0 +1,52 @@ +import 'package:cloudtech_calculator/theme_model.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class SecondRoute extends StatefulWidget { + @override + _SecondRouteState createState() => _SecondRouteState(); +} + +class _SecondRouteState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("Настройки калькулятора", + style: TextStyle(color: Theme.of(context).accentColor)), + shadowColor: const Color(0x00000000), + ), + body: Container( + color: Theme.of(context).primaryColor, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: ListView( + padding: const EdgeInsets.all(8), + children: [ + ListTile( + leading: IconButton( + icon: Icon( + Icons.settings_display, + color: Theme.of(context).accentColor, + ), + onPressed: null), + title: Text( + "Светлая тема", + style: TextStyle( + fontWeight: FontWeight.w500, + color: Theme.of(context).accentColor), + ), + trailing: Switch( + value: Theme.of(context).brightness == Brightness.light, + onChanged: (value) { + Provider.of(context, listen: false) + .toggleTheme(); + }, + ), + ) + ], + ), + )), + ); + } +} diff --git a/lib/theme.dart b/lib/theme.dart index 8b834bc..b373ce6 100644 --- a/lib/theme.dart +++ b/lib/theme.dart @@ -1,13 +1,15 @@ import 'package:flutter/material.dart'; -ThemeData darkTheme = ThemeData.dark().copyWith( +ThemeData darkTheme = ThemeData( primaryColor: const Color(0xff131618), accentColor: Colors.white, + brightness: Brightness.dark, textTheme: const TextTheme(bodyText2: TextStyle(color: Color(0xffffffff))), ); -ThemeData lightTheme = ThemeData.light().copyWith( +ThemeData lightTheme = ThemeData( primaryColor: Colors.white, accentColor: Colors.green, + brightness: Brightness.light, textTheme: const TextTheme(bodyText2: TextStyle(color: Colors.green)), );