Compare commits
No commits in common. "master" and "v1.0" have entirely different histories.
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
// 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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,8 +1,4 @@
|
|||||||
import 'package:auto_size_text/auto_size_text.dart';
|
|
||||||
import 'package:cloudtech_calculator/theme_model.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'route.dart';
|
|
||||||
|
|
||||||
enum Operation {
|
enum Operation {
|
||||||
plus,
|
plus,
|
||||||
@ -61,17 +57,21 @@ extension NumbersExtension on num {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() => runApp(ChangeNotifierProvider<ThemeModel>(
|
void main() {
|
||||||
create: (BuildContext context) => ThemeModel(), child: MyApp()));
|
runApp(MyApp());
|
||||||
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
// This widget is the root of your application.
|
// This widget is the root of your application.
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
title: 'Calculator',
|
||||||
theme: Provider.of<ThemeModel>(context).currentTheme,
|
theme: ThemeData(
|
||||||
home: const MyHomePage(title: 'Калькулятор'),
|
primarySwatch: Colors.blue,
|
||||||
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||||
|
),
|
||||||
|
home: const MyHomePage(title: 'Calculator'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,25 +249,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(widget.title,
|
title: Text(widget.title),
|
||||||
style: TextStyle(color: Theme.of(context).accentColor)),
|
|
||||||
shadowColor: const Color(0x00000000),
|
|
||||||
actions: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.settings),
|
|
||||||
tooltip: 'Show Snackbar',
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => SecondRoute()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
color: Theme.of(context).accentColor,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
color: Theme.of(context).primaryColor,
|
color: const Color(0xFF4b44cf),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -276,12 +261,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: AutoSizeText(
|
child: Text(
|
||||||
textResh,
|
textResh,
|
||||||
style: TextStyle(
|
style: const TextStyle(fontSize: 80, color: Colors.white),
|
||||||
fontSize: 70, color: Theme.of(context).accentColor),
|
),
|
||||||
maxLines: 1,
|
),
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@ -382,14 +366,13 @@ class CallButton extends StatelessWidget {
|
|||||||
width: 100,
|
width: 100,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
color: const Color(0x00000000)),
|
color: const Color(0xE0E0E0E0)),
|
||||||
child: FlatButton(
|
child: FlatButton(
|
||||||
height: 60,
|
height: 60,
|
||||||
onPressed: () => onPressed(value),
|
onPressed: () => onPressed(value),
|
||||||
child: Text(
|
child: Text(
|
||||||
text,
|
text,
|
||||||
style:
|
style: TextStyle(fontSize: 40, color: Colors.blue[900]),
|
||||||
TextStyle(fontSize: 30, color: Theme.of(context).accentColor),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,52 +0,0 @@
|
|||||||
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<SecondRoute> {
|
|
||||||
@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<ThemeModel>(context, listen: false)
|
|
||||||
.toggleTheme();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
ThemeData darkTheme = ThemeData(
|
|
||||||
primaryColor: const Color(0xff131618),
|
|
||||||
accentColor: Colors.white,
|
|
||||||
brightness: Brightness.dark,
|
|
||||||
textTheme: const TextTheme(bodyText2: TextStyle(color: Color(0xffffffff))),
|
|
||||||
);
|
|
||||||
|
|
||||||
ThemeData lightTheme = ThemeData(
|
|
||||||
primaryColor: Colors.white,
|
|
||||||
accentColor: Colors.green,
|
|
||||||
brightness: Brightness.light,
|
|
||||||
textTheme: const TextTheme(bodyText2: TextStyle(color: Colors.green)),
|
|
||||||
);
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'theme.dart';
|
|
||||||
|
|
||||||
enum ThemeType { lightTheme, darkTheme }
|
|
||||||
|
|
||||||
class ThemeModel extends ChangeNotifier {
|
|
||||||
ThemeData currentTheme = darkTheme;
|
|
||||||
ThemeType _themeType = ThemeType.darkTheme;
|
|
||||||
|
|
||||||
void toggleTheme() {
|
|
||||||
if (_themeType == ThemeType.darkTheme) {
|
|
||||||
currentTheme = lightTheme;
|
|
||||||
_themeType = ThemeType.lightTheme;
|
|
||||||
return notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_themeType == ThemeType.lightTheme) {
|
|
||||||
currentTheme = darkTheme;
|
|
||||||
_themeType = ThemeType.darkTheme;
|
|
||||||
return notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
22
pubspec.lock
22
pubspec.lock
@ -8,13 +8,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.0-nullsafety.1"
|
version: "2.5.0-nullsafety.1"
|
||||||
auto_size_text:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: auto_size_text
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.0"
|
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -95,13 +88,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0-nullsafety.3"
|
version: "1.3.0-nullsafety.3"
|
||||||
nested:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: nested
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.0.4"
|
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -109,13 +95,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0-nullsafety.1"
|
version: "1.8.0-nullsafety.1"
|
||||||
provider:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: provider
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "4.3.2+2"
|
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -179,4 +158,3 @@ packages:
|
|||||||
version: "2.1.0-nullsafety.3"
|
version: "2.1.0-nullsafety.3"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.10.0-110 <2.11.0"
|
dart: ">=2.10.0-110 <2.11.0"
|
||||||
flutter: ">=1.16.0"
|
|
||||||
|
|||||||
@ -27,8 +27,7 @@ dependencies:
|
|||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.0
|
cupertino_icons: ^1.0.0
|
||||||
provider: ^4.3.2+2
|
|
||||||
auto_size_text: ^2.1.0
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user