cake_wallet/lib/src/widgets/standart_switch.dart

42 lines
1.2 KiB
Dart
Raw Normal View History

import 'package:cake_wallet/palette.dart';
import 'package:flutter/cupertino.dart';
2020-01-04 19:31:52 +00:00
import 'package:flutter/material.dart';
class StandartSwitch extends StatefulWidget {
2020-01-08 12:26:34 +00:00
const StandartSwitch({@required this.value, @required this.onTaped});
2020-01-04 19:31:52 +00:00
final bool value;
final VoidCallback onTaped;
@override
2020-01-08 12:26:34 +00:00
StandartSwitchState createState() => StandartSwitchState();
2020-01-04 19:31:52 +00:00
}
class StandartSwitchState extends State<StandartSwitch> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: widget.onTaped,
child: AnimatedContainer(
padding: EdgeInsets.only(left: 2.0, right: 2.0),
2020-01-08 12:26:34 +00:00
alignment: widget.value ? Alignment.centerRight : Alignment.centerLeft,
2020-01-04 19:31:52 +00:00
duration: Duration(milliseconds: 250),
width: 50,
height: 28,
2020-01-04 19:31:52 +00:00
decoration: BoxDecoration(
color: widget.value
? Colors.green
: PaletteDark.mainBackgroundColor,
borderRadius: BorderRadius.all(Radius.circular(14.0))),
2020-01-04 19:31:52 +00:00
child: Container(
width: 24.0,
height: 24.0,
2020-01-04 19:31:52 +00:00
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle),
2020-01-04 19:31:52 +00:00
),
),
);
}
2020-01-08 12:26:34 +00:00
}