Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3665004748 | |||
| b5b1be28e0 | |||
| 45803c6519 |
BIN
google_fonts/Rubik-Black.ttf
Normal file
BIN
google_fonts/Rubik-Black.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-BlackItalic.ttf
Normal file
BIN
google_fonts/Rubik-BlackItalic.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-Bold.ttf
Normal file
BIN
google_fonts/Rubik-Bold.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-BoldItalic.ttf
Normal file
BIN
google_fonts/Rubik-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-ExtraBold.ttf
Normal file
BIN
google_fonts/Rubik-ExtraBold.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-ExtraBoldItalic.ttf
Normal file
BIN
google_fonts/Rubik-ExtraBoldItalic.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-Italic.ttf
Normal file
BIN
google_fonts/Rubik-Italic.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-Light.ttf
Normal file
BIN
google_fonts/Rubik-Light.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-LightItalic.ttf
Normal file
BIN
google_fonts/Rubik-LightItalic.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-Medium.ttf
Normal file
BIN
google_fonts/Rubik-Medium.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-MediumItalic.ttf
Normal file
BIN
google_fonts/Rubik-MediumItalic.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-Regular.ttf
Normal file
BIN
google_fonts/Rubik-Regular.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-SemiBold.ttf
Normal file
BIN
google_fonts/Rubik-SemiBold.ttf
Normal file
Binary file not shown.
BIN
google_fonts/Rubik-SemiBoldItalic.ttf
Normal file
BIN
google_fonts/Rubik-SemiBoldItalic.ttf
Normal file
Binary file not shown.
94
lib/bloc/getcalc_bloc.dart
Normal file
94
lib/bloc/getcalc_bloc.dart
Normal file
@ -0,0 +1,94 @@
|
||||
import 'dart:async';
|
||||
import 'package:cloudtech_calculator/extension.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
part 'getcalc_event.dart';
|
||||
part 'getcalc_state.dart';
|
||||
|
||||
class CalcEventBloc extends Bloc<CalcEvent, CalcEventState> {
|
||||
CalcEventBloc() : super(const EmptyState());
|
||||
|
||||
@override
|
||||
Stream<CalcEventState> mapEventToState(
|
||||
CalcEvent event,
|
||||
) async* {
|
||||
num a;
|
||||
num b;
|
||||
final lastState = state;
|
||||
if (event is NumberEvent) {
|
||||
if (lastState is EmptyState) {
|
||||
yield FirstState(a: event.value);
|
||||
} else if (lastState is FirstState) {
|
||||
a = lastState.a.concat(pointer: false, value: event.value);
|
||||
yield FirstState(a: a);
|
||||
} else if (lastState is OperatorState &&
|
||||
lastState.pointStatus == true &&
|
||||
lastState.operator == Operator.point &&
|
||||
lastState.b == null) {
|
||||
a = lastState.a.concat(pointer: true, value: event.value);
|
||||
yield FirstState(a: a);
|
||||
} else if (lastState is OperatorState &&
|
||||
lastState.operator != Operator.point &&
|
||||
lastState.b == null) {
|
||||
yield SecondState(
|
||||
a: lastState.a, b: event.value, operator: lastState.operator);
|
||||
} else if (lastState is SecondState && lastState.b != null) {
|
||||
b = lastState.b.concat(pointer: false, value: event.value);
|
||||
yield SecondState(a: lastState.a, b: b, operator: lastState.operator);
|
||||
} else if (lastState is OperatorState && lastState.b != null) {
|
||||
b = lastState.b.concat(pointer: true, value: event.value);
|
||||
yield SecondState(a: lastState.a, b: b, operator: lastState.operator);
|
||||
}
|
||||
} else if (event is PlusOperationEvent) {
|
||||
yield OperatorState(a: (state as FirstState).a, operator: Operator.plus);
|
||||
} else if (event is MinusOperationEvent) {
|
||||
yield OperatorState(a: (state as FirstState).a, operator: Operator.minus);
|
||||
} else if (event is DivisionOperationEvent) {
|
||||
yield OperatorState(a: (state as FirstState).a, operator: Operator.div);
|
||||
} else if (event is MultiOperationEvent) {
|
||||
yield OperatorState(a: (state as FirstState).a, operator: Operator.multi);
|
||||
} else if (event is PointOperationEvent) {
|
||||
if (lastState is FirstState) {
|
||||
yield OperatorState(
|
||||
a: lastState.a, operator: Operator.point, pointStatus: true);
|
||||
} else if (lastState is SecondState) {
|
||||
yield OperatorState(
|
||||
a: lastState.a,
|
||||
b: lastState.b,
|
||||
operator: lastState.operator,
|
||||
pointStatus: true);
|
||||
}
|
||||
} else if (event is PercentOperationEvent) {
|
||||
if (lastState is FirstState) {
|
||||
a = lastState.a / 100;
|
||||
yield FirstState(a: a);
|
||||
} else if (lastState is SecondState) {
|
||||
b = lastState.b / 100;
|
||||
yield SecondState(a: lastState.a, b: b, operator: lastState.operator);
|
||||
}
|
||||
} else if (event is PlusMinusOperationEvent) {
|
||||
if (lastState is FirstState) {
|
||||
a = lastState.a * (-1);
|
||||
yield FirstState(a: a);
|
||||
} else if (lastState is SecondState) {
|
||||
b = lastState.b * (-1);
|
||||
yield SecondState(a: lastState.a, b: b, operator: lastState.operator);
|
||||
}
|
||||
} else if (event is BackspaceOperationEvent) {
|
||||
if (lastState is FirstState) {
|
||||
a = lastState.a.backspace();
|
||||
yield FirstState(a: a);
|
||||
} else if (lastState is SecondState) {
|
||||
b = lastState.b.backspace();
|
||||
yield SecondState(a: lastState.a, b: b, operator: lastState.operator);
|
||||
}
|
||||
} else if (event is ClearAllOperationEvent) {
|
||||
yield const EmptyState();
|
||||
} else if (event is ResultOperationEvent) {
|
||||
if (lastState is SecondState) {
|
||||
yield FirstState(
|
||||
a: operationEvent(lastState.a, lastState.b, lastState.operator));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
lib/bloc/getcalc_event.dart
Normal file
29
lib/bloc/getcalc_event.dart
Normal file
@ -0,0 +1,29 @@
|
||||
part of 'getcalc_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class CalcEvent {}
|
||||
|
||||
class NumberEvent extends CalcEvent {
|
||||
final int value;
|
||||
NumberEvent(this.value);
|
||||
}
|
||||
|
||||
class PlusOperationEvent extends CalcEvent {}
|
||||
|
||||
class MinusOperationEvent extends CalcEvent {}
|
||||
|
||||
class DivisionOperationEvent extends CalcEvent {}
|
||||
|
||||
class MultiOperationEvent extends CalcEvent {}
|
||||
|
||||
class PointOperationEvent extends CalcEvent {}
|
||||
|
||||
class PercentOperationEvent extends CalcEvent {}
|
||||
|
||||
class PlusMinusOperationEvent extends CalcEvent {}
|
||||
|
||||
class BackspaceOperationEvent extends CalcEvent {}
|
||||
|
||||
class ClearAllOperationEvent extends CalcEvent {}
|
||||
|
||||
class ResultOperationEvent extends CalcEvent {}
|
||||
36
lib/bloc/getcalc_state.dart
Normal file
36
lib/bloc/getcalc_state.dart
Normal file
@ -0,0 +1,36 @@
|
||||
part of 'getcalc_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class CalcEventState {
|
||||
const CalcEventState();
|
||||
}
|
||||
|
||||
class EmptyState extends CalcEventState {
|
||||
const EmptyState();
|
||||
}
|
||||
|
||||
class FirstState extends CalcEventState {
|
||||
final num a;
|
||||
const FirstState({this.a});
|
||||
}
|
||||
|
||||
class OperatorState extends CalcEventState {
|
||||
final num a;
|
||||
final num b;
|
||||
final Operator operator;
|
||||
final bool pointStatus;
|
||||
const OperatorState({this.a, this.b, this.operator, this.pointStatus});
|
||||
}
|
||||
|
||||
class SecondState extends CalcEventState {
|
||||
final num a, b;
|
||||
final Operator operator;
|
||||
const SecondState({this.a, this.b, this.operator});
|
||||
}
|
||||
|
||||
class ResultState extends CalcEventState {
|
||||
final num a, b;
|
||||
final Operator operator;
|
||||
final num result;
|
||||
const ResultState({this.a, this.b, this.operator, this.result});
|
||||
}
|
||||
81
lib/extension.dart
Normal file
81
lib/extension.dart
Normal file
@ -0,0 +1,81 @@
|
||||
enum Operator {
|
||||
plus,
|
||||
minus,
|
||||
div,
|
||||
multi,
|
||||
percent,
|
||||
plusminus,
|
||||
backspace,
|
||||
clearall,
|
||||
point,
|
||||
result
|
||||
}
|
||||
|
||||
extension OperationExtension on Operator {
|
||||
String getString() {
|
||||
switch (this) {
|
||||
case Operator.plus:
|
||||
return " + ";
|
||||
case Operator.minus:
|
||||
return " - ";
|
||||
case Operator.multi:
|
||||
return " x ";
|
||||
case Operator.div:
|
||||
return " ÷ ";
|
||||
case Operator.point:
|
||||
return ".";
|
||||
case Operator.result:
|
||||
return " = ";
|
||||
default:
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension NumbersExtension on num {
|
||||
num backspace() {
|
||||
String pull = "$this";
|
||||
pull = pull.substring(0, pull.length - 1);
|
||||
if (pull.isNotEmpty && pull.split('').last.contains('.')) {
|
||||
pull = pull.substring(0, pull.length - 1);
|
||||
}
|
||||
return num.parse(pull, (pull) => 0);
|
||||
}
|
||||
|
||||
num concat({bool pointer, int value}) {
|
||||
if (pointer == true) {
|
||||
final String pull = "${this}." + "$value";
|
||||
return num.parse(pull);
|
||||
} else {
|
||||
final String pull = "$this" + "$value";
|
||||
return num.parse(pull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
num operationEvent(num x, num y, Operator op) {
|
||||
num result = 0;
|
||||
switch (op) {
|
||||
case Operator.plus:
|
||||
result = x + y;
|
||||
break;
|
||||
case Operator.minus:
|
||||
result = x - y;
|
||||
break;
|
||||
case Operator.multi:
|
||||
result = x * y;
|
||||
break;
|
||||
case Operator.div:
|
||||
result = x / y;
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (result % 1 == 0) {
|
||||
return result.toInt();
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
417
lib/main.dart
417
lib/main.dart
@ -1,66 +1,13 @@
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:cloudtech_calculator/extension.dart';
|
||||
import 'package:cloudtech_calculator/theme_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'bloc/getcalc_bloc.dart';
|
||||
import 'route.dart';
|
||||
|
||||
enum Operation {
|
||||
plus,
|
||||
minus,
|
||||
multi,
|
||||
div,
|
||||
point,
|
||||
res,
|
||||
percent,
|
||||
plusMinus,
|
||||
backspace,
|
||||
clear
|
||||
}
|
||||
|
||||
extension OperationExtension on Operation {
|
||||
String getString() {
|
||||
switch (this) {
|
||||
case Operation.plus:
|
||||
return "+";
|
||||
case Operation.minus:
|
||||
return "-";
|
||||
case Operation.multi:
|
||||
return "x";
|
||||
case Operation.div:
|
||||
return "÷";
|
||||
case Operation.point:
|
||||
return ".";
|
||||
case Operation.res:
|
||||
return "=";
|
||||
default:
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Numbers { zero, one, two, three, four, five, six, seven, eight, nine }
|
||||
|
||||
extension NumbersExtension on num {
|
||||
num backspace() {
|
||||
String pull = "$this";
|
||||
pull = pull.substring(0, pull.length - 1);
|
||||
if (pull.isNotEmpty && pull.split('').last.contains('.')) {
|
||||
pull = pull.substring(0, pull.length - 1);
|
||||
}
|
||||
return num.parse(pull, (pull) => 0);
|
||||
}
|
||||
|
||||
num concat({bool pointer, int value}) {
|
||||
if (pointer == true) {
|
||||
final String pull = "${this}." + "$value";
|
||||
return num.parse(pull);
|
||||
} else {
|
||||
final String pull = "$this" + "$value";
|
||||
return num.parse(pull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main() => runApp(ChangeNotifierProvider<ThemeModel>(
|
||||
create: (BuildContext context) => ThemeModel(), child: MyApp()));
|
||||
|
||||
@ -71,198 +18,47 @@ class MyApp extends StatelessWidget {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: Provider.of<ThemeModel>(context).currentTheme,
|
||||
home: const MyHomePage(title: 'Калькулятор'),
|
||||
home: MyHomePage(title: 'Калькулятор'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({Key key, this.title}) : super(key: key);
|
||||
class MyHomePage extends StatelessWidget {
|
||||
MyHomePage({Key key, this.title}) : super(key: key);
|
||||
final String title;
|
||||
|
||||
@override
|
||||
_MyHomePageState createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
num a, b;
|
||||
bool pointStatus;
|
||||
dynamic operator;
|
||||
String textResh = "0";
|
||||
|
||||
void getCalc(dynamic type) {
|
||||
if (type is Numbers) {
|
||||
if (a == null) {
|
||||
a = type.index;
|
||||
|
||||
setState(() {
|
||||
textResh = '$a';
|
||||
});
|
||||
} else if (a != null && operator == null) {
|
||||
if (pointStatus == true) {
|
||||
a = a.concat(pointer: true, value: type.index);
|
||||
pointStatus = false;
|
||||
} else {
|
||||
a = a.concat(pointer: false, value: type.index);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
textResh = '$a';
|
||||
});
|
||||
} else if (operator != null) {
|
||||
if (b == null) {
|
||||
b = type.index;
|
||||
setState(() {
|
||||
textResh = "$a ${(operator as Operation).getString()} $b";
|
||||
});
|
||||
} else if (b != null) {
|
||||
if (pointStatus == true) {
|
||||
b = b.concat(pointer: true, value: type.index);
|
||||
pointStatus = false;
|
||||
} else {
|
||||
b = b.concat(pointer: false, value: type.index);
|
||||
}
|
||||
pointStatus = false;
|
||||
|
||||
setState(() {
|
||||
textResh = "$a ${(operator as Operation).getString()} $b";
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (type is Operation) {
|
||||
if (type == Operation.res) {
|
||||
setState(() {
|
||||
textResh = "$a ${(operator as Operation).getString()} $b";
|
||||
});
|
||||
a = operationEvent(a, b, operator as Operation);
|
||||
b = null;
|
||||
operator = null;
|
||||
setState(() {
|
||||
textResh = "$a";
|
||||
});
|
||||
} else if (type == Operation.point) {
|
||||
if (a != null && b == null) {
|
||||
if (a is double) {
|
||||
pointStatus = false;
|
||||
setState(() {
|
||||
textResh = "$a";
|
||||
});
|
||||
} else {
|
||||
pointStatus = true;
|
||||
setState(() {
|
||||
textResh = "$a.";
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (b is double) {
|
||||
pointStatus = false;
|
||||
setState(() {
|
||||
textResh = "$a ${(operator as Operation).getString()} $b";
|
||||
});
|
||||
} else {
|
||||
pointStatus = true;
|
||||
setState(() {
|
||||
textResh = "$a ${(operator as Operation).getString()} $b.";
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (type == Operation.clear) {
|
||||
a = 0;
|
||||
b = null;
|
||||
operator = null;
|
||||
setState(() {
|
||||
textResh = "$a";
|
||||
});
|
||||
} else if (type == Operation.backspace) {
|
||||
if (a != null && b == null) {
|
||||
a = a.backspace();
|
||||
setState(() {
|
||||
textResh = "$a";
|
||||
});
|
||||
} else {
|
||||
b = b.backspace();
|
||||
setState(() {
|
||||
textResh = "$a ${(operator as Operation).getString()} $b";
|
||||
});
|
||||
}
|
||||
} else if (type == Operation.plusMinus) {
|
||||
if (a != null && b == null) {
|
||||
a = a * -1;
|
||||
setState(() {
|
||||
textResh = "$a";
|
||||
});
|
||||
} else {
|
||||
b = b * -1;
|
||||
setState(() {
|
||||
textResh = "$a ${(operator as Operation).getString()} $b";
|
||||
});
|
||||
}
|
||||
} else if (type == Operation.percent) {
|
||||
if (a != null && b == null) {
|
||||
a = a / 100;
|
||||
setState(() {
|
||||
textResh = "$a";
|
||||
});
|
||||
} else {
|
||||
b = b / 100;
|
||||
setState(() {
|
||||
textResh = "$a ${(operator as Operation).getString()} $b";
|
||||
});
|
||||
}
|
||||
} else {
|
||||
operator = type;
|
||||
setState(() {
|
||||
textResh = "$a ${(operator as Operation).getString()}";
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
num operationEvent(num x, num y, Operation op) {
|
||||
num result = 0;
|
||||
switch (op) {
|
||||
case Operation.plus:
|
||||
result = x + y;
|
||||
break;
|
||||
case Operation.minus:
|
||||
result = x - y;
|
||||
break;
|
||||
case Operation.multi:
|
||||
result = x * y;
|
||||
break;
|
||||
case Operation.div:
|
||||
result = x / y;
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (result % 1 == 0) {
|
||||
return result.toInt();
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
final _getCalc = CalcEventBloc();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title,
|
||||
title: Text(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()),
|
||||
);
|
||||
PopupMenuButton(
|
||||
itemBuilder: (context) => [
|
||||
const PopupMenuItem(
|
||||
value: 1,
|
||||
child: Text("Настройки темы"),
|
||||
),
|
||||
const PopupMenuItem(
|
||||
value: 2,
|
||||
child: Text("Курс валют"),
|
||||
),
|
||||
],
|
||||
onSelected: (value) {
|
||||
if (value == 1) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => SecondRoute()),
|
||||
);
|
||||
} else {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => CursState()),
|
||||
);
|
||||
}
|
||||
},
|
||||
color: Theme.of(context).accentColor,
|
||||
)
|
||||
],
|
||||
),
|
||||
@ -275,85 +71,148 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: AutoSizeText(
|
||||
textResh,
|
||||
style: TextStyle(
|
||||
fontSize: 70, color: Theme.of(context).accentColor),
|
||||
maxLines: 1,
|
||||
)),
|
||||
alignment: Alignment.centerRight,
|
||||
child: BlocBuilder<CalcEventBloc, CalcEventState>(
|
||||
cubit: _getCalc,
|
||||
builder: (context, state) {
|
||||
if (state is EmptyState) {
|
||||
return AutoSizeText(
|
||||
"0",
|
||||
style: TextStyle(
|
||||
fontSize: 70,
|
||||
color: Theme.of(context).accentColor),
|
||||
maxLines: 1,
|
||||
);
|
||||
} else if (state is FirstState) {
|
||||
return AutoSizeText(
|
||||
state.a.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 70,
|
||||
color: Theme.of(context).accentColor),
|
||||
maxLines: 1,
|
||||
);
|
||||
} else if (state is OperatorState &&
|
||||
state.b == null) {
|
||||
return AutoSizeText(
|
||||
"${state.a}${state.operator.getString()}",
|
||||
style: TextStyle(
|
||||
fontSize: 70,
|
||||
color: Theme.of(context).accentColor),
|
||||
maxLines: 1,
|
||||
);
|
||||
} else if (state is OperatorState &&
|
||||
state.b != null) {
|
||||
return AutoSizeText(
|
||||
"${state.a}${state.operator.getString()}${state.b}.",
|
||||
style: TextStyle(
|
||||
fontSize: 70,
|
||||
color: Theme.of(context).accentColor),
|
||||
maxLines: 1,
|
||||
);
|
||||
} else if (state is SecondState) {
|
||||
return AutoSizeText(
|
||||
"${state.a}${state.operator.getString()}${state.b}",
|
||||
style: TextStyle(
|
||||
fontSize: 70,
|
||||
color: Theme.of(context).accentColor),
|
||||
maxLines: 1,
|
||||
);
|
||||
} else if (state is ResultState) {
|
||||
return AutoSizeText(
|
||||
"${state.result}",
|
||||
style: TextStyle(
|
||||
fontSize: 70,
|
||||
color: Theme.of(context).accentColor),
|
||||
maxLines: 1,
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox.shrink();
|
||||
}),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
CallButton(
|
||||
text: "±",
|
||||
value: Operation.plusMinus,
|
||||
onPressed: getCalc,
|
||||
),
|
||||
text: "±",
|
||||
onPressed: () =>
|
||||
_getCalc.add(PlusMinusOperationEvent())),
|
||||
CallButton(
|
||||
text: "%",
|
||||
value: Operation.percent,
|
||||
onPressed: getCalc),
|
||||
onPressed: () => _getCalc.add(PercentOperationEvent())),
|
||||
CallButton(
|
||||
text: "⌫",
|
||||
value: Operation.backspace,
|
||||
onPressed: getCalc),
|
||||
onPressed: () =>
|
||||
_getCalc.add(BackspaceOperationEvent())),
|
||||
CallButton(
|
||||
text: "AC", value: Operation.clear, onPressed: getCalc),
|
||||
text: "AC",
|
||||
onPressed: () =>
|
||||
_getCalc.add(ClearAllOperationEvent())),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
CallButton(
|
||||
text: "7",
|
||||
value: Numbers.seven,
|
||||
onPressed: getCalc,
|
||||
),
|
||||
text: "7",
|
||||
onPressed: () => _getCalc.add(NumberEvent(7))),
|
||||
CallButton(
|
||||
text: "8", value: Numbers.eight, onPressed: getCalc),
|
||||
text: "8",
|
||||
onPressed: () => _getCalc.add(NumberEvent(8))),
|
||||
CallButton(
|
||||
text: "9", value: Numbers.nine, onPressed: getCalc),
|
||||
text: "9",
|
||||
onPressed: () => _getCalc.add(NumberEvent(9))),
|
||||
CallButton(
|
||||
text: "/", value: Operation.div, onPressed: getCalc),
|
||||
text: "/",
|
||||
onPressed: () =>
|
||||
_getCalc.add(DivisionOperationEvent())),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
CallButton(
|
||||
text: "4", value: Numbers.four, onPressed: getCalc),
|
||||
text: "4",
|
||||
onPressed: () => _getCalc.add(NumberEvent(4))),
|
||||
CallButton(
|
||||
text: "5", value: Numbers.five, onPressed: getCalc),
|
||||
text: "5",
|
||||
onPressed: () => _getCalc.add(NumberEvent(5))),
|
||||
CallButton(
|
||||
text: "6", value: Numbers.six, onPressed: getCalc),
|
||||
text: "6",
|
||||
onPressed: () => _getCalc.add(NumberEvent(6))),
|
||||
CallButton(
|
||||
text: "*", value: Operation.multi, onPressed: getCalc),
|
||||
text: "*",
|
||||
onPressed: () => _getCalc.add(MultiOperationEvent())),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
CallButton(
|
||||
text: "1", value: Numbers.one, onPressed: getCalc),
|
||||
text: "1",
|
||||
onPressed: () => _getCalc.add(NumberEvent(1))),
|
||||
CallButton(
|
||||
text: "2", value: Numbers.two, onPressed: getCalc),
|
||||
text: "2",
|
||||
onPressed: () => _getCalc.add(NumberEvent(2))),
|
||||
CallButton(
|
||||
text: "3", value: Numbers.three, onPressed: getCalc),
|
||||
text: "3",
|
||||
onPressed: () => _getCalc.add(NumberEvent(3))),
|
||||
CallButton(
|
||||
text: "-", value: Operation.minus, onPressed: getCalc),
|
||||
text: "-",
|
||||
onPressed: () => _getCalc.add(MinusOperationEvent())),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
CallButton(
|
||||
text: "0", value: Numbers.zero, onPressed: getCalc),
|
||||
text: "0",
|
||||
onPressed: () => _getCalc.add(NumberEvent(0))),
|
||||
CallButton(
|
||||
text: ".", value: Operation.point, onPressed: getCalc),
|
||||
text: ".",
|
||||
onPressed: () => _getCalc.add(PointOperationEvent())),
|
||||
CallButton(
|
||||
text: "=", value: Operation.res, onPressed: getCalc),
|
||||
text: "=",
|
||||
onPressed: () => _getCalc.add(ResultOperationEvent())),
|
||||
CallButton(
|
||||
text: "+",
|
||||
value: Operation.plus,
|
||||
onPressed: getCalc,
|
||||
),
|
||||
text: "+",
|
||||
onPressed: () => _getCalc.add(PlusOperationEvent())),
|
||||
],
|
||||
),
|
||||
],
|
||||
@ -365,12 +224,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
|
||||
class CallButton extends StatelessWidget {
|
||||
final String text;
|
||||
final dynamic value;
|
||||
|
||||
final void Function(dynamic) onPressed;
|
||||
|
||||
const CallButton(
|
||||
{@required this.text, @required this.value, @required this.onPressed});
|
||||
final void Function() onPressed;
|
||||
const CallButton({@required this.text, @required this.onPressed});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -385,7 +240,7 @@ class CallButton extends StatelessWidget {
|
||||
color: const Color(0x00000000)),
|
||||
child: FlatButton(
|
||||
height: 60,
|
||||
onPressed: () => onPressed(value),
|
||||
onPressed: () => onPressed(),
|
||||
child: Text(
|
||||
text,
|
||||
style:
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import 'package:cloudtech_calculator/theme_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class SecondRoute extends StatefulWidget {
|
||||
@ -43,6 +44,99 @@ class _SecondRouteState extends State<SecondRoute> {
|
||||
.toggleTheme();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CursState extends StatefulWidget {
|
||||
@override
|
||||
_CursRouteState createState() => _CursRouteState();
|
||||
}
|
||||
|
||||
class _CursRouteState extends State<CursState> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
"NOTHING",
|
||||
style: GoogleFonts.rubik(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).accentColor,
|
||||
letterSpacing: 3.06,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
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: [
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Theme.of(context).backgroundColor,
|
||||
),
|
||||
child: ListTile(
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.settings_display,
|
||||
color: Theme.of(context).accentColor,
|
||||
),
|
||||
onPressed: null),
|
||||
title: Text(
|
||||
"USD",
|
||||
style: GoogleFonts.rubik(
|
||||
fontSize: 21,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Theme.of(context).accentColor),
|
||||
),
|
||||
trailing: Text(
|
||||
"77,96 ₽",
|
||||
style: GoogleFonts.rubik(
|
||||
fontSize: 21,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).accentColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Theme.of(context).backgroundColor,
|
||||
),
|
||||
child: ListTile(
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.settings_display,
|
||||
color: Theme.of(context).accentColor,
|
||||
),
|
||||
onPressed: null),
|
||||
title: Text(
|
||||
"USD",
|
||||
style: GoogleFonts.rubik(
|
||||
fontSize: 21,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Theme.of(context).accentColor),
|
||||
),
|
||||
trailing: Text(
|
||||
"77,96 ₽",
|
||||
style: GoogleFonts.rubik(
|
||||
fontSize: 21,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).accentColor),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
ThemeData darkTheme = ThemeData(
|
||||
primaryColor: const Color(0xff131618),
|
||||
accentColor: Colors.white,
|
||||
primaryColor: const Color(0xff20274C),
|
||||
accentColor: const Color(0xffD4D9EC),
|
||||
backgroundColor: const Color(0xff414d7b),
|
||||
brightness: Brightness.dark,
|
||||
textTheme: const TextTheme(bodyText2: TextStyle(color: Color(0xffffffff))),
|
||||
);
|
||||
@ -10,6 +11,7 @@ ThemeData darkTheme = ThemeData(
|
||||
ThemeData lightTheme = ThemeData(
|
||||
primaryColor: Colors.white,
|
||||
accentColor: Colors.green,
|
||||
backgroundColor: const Color(0xff414d7b),
|
||||
brightness: Brightness.light,
|
||||
textTheme: const TextTheme(bodyText2: TextStyle(color: Colors.green)),
|
||||
);
|
||||
|
||||
149
pubspec.lock
149
pubspec.lock
@ -15,6 +15,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
bloc:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: bloc
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -50,6 +57,20 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.15.0-nullsafety.3"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.5"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -64,16 +85,65 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0-nullsafety.1"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.2.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_bloc:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_bloc
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.6"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
google_fonts:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: google_fonts
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.2"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.4"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: intl
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.16.1"
|
||||
lint:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@ -109,6 +179,69 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0-nullsafety.1"
|
||||
path_provider:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.21"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1+2"
|
||||
path_provider_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.4+4"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
path_provider_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.4+1"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.2"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: process
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.13"
|
||||
provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -177,6 +310,20 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0-nullsafety.3"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.3"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.2"
|
||||
sdks:
|
||||
dart: ">=2.10.0-110 <2.11.0"
|
||||
flutter: ">=1.16.0"
|
||||
flutter: ">=1.17.0 <2.0.0"
|
||||
|
||||
58
pubspec.yaml
58
pubspec.yaml
@ -1,20 +1,8 @@
|
||||
name: cloudtech_calculator
|
||||
description: A new Flutter project.
|
||||
|
||||
# The following line prevents the package from being accidentally published to
|
||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
# The following defines the version and build number for your application.
|
||||
# A version number is three numbers separated by dots, like 1.2.43
|
||||
# followed by an optional build number separated by a +.
|
||||
# Both the version and the builder number may be overridden in flutter
|
||||
# build by specifying --build-name and --build-number, respectively.
|
||||
# In Android, build-name is used as versionName while build-number used as versionCode.
|
||||
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
|
||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
@ -23,52 +11,20 @@ environment:
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.0
|
||||
provider: ^4.3.2+2
|
||||
auto_size_text: ^2.1.0
|
||||
bloc: ^6.0.3
|
||||
cupertino_icons: ^1.0.0
|
||||
flutter_bloc: ^6.0.6
|
||||
google_fonts: ^1.1.1
|
||||
provider: ^4.3.2+2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
lint: ^1.2.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
uses-material-design: true
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||
# For details regarding adding assets from package dependencies, see
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
# To add custom fonts to your application, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts from package dependencies,
|
||||
# see https://flutter.dev/custom-fonts/#from-packages
|
||||
|
||||
assets:
|
||||
- google_fonts/
|
||||
Loading…
x
Reference in New Issue
Block a user