2020-05-21 18:01:12 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class StandartSwitch extends StatefulWidget {
|
2022-10-12 17:09:57 +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(
|
2020-05-21 18:01:12 +00:00
|
|
|
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),
|
2020-05-21 18:01:12 +00:00
|
|
|
width: 50,
|
|
|
|
height: 28,
|
2020-01-04 19:31:52 +00:00
|
|
|
decoration: BoxDecoration(
|
2020-05-21 18:01:12 +00:00
|
|
|
color: widget.value
|
2022-10-12 17:09:57 +00:00
|
|
|
? Theme.of(context).accentTextTheme!.bodyText1!.color!
|
|
|
|
: Theme.of(context).accentTextTheme!.headline1!.color!,
|
2020-05-21 18:01:12 +00:00
|
|
|
borderRadius: BorderRadius.all(Radius.circular(14.0))),
|
2020-01-04 19:31:52 +00:00
|
|
|
child: Container(
|
2020-05-21 18:01:12 +00:00
|
|
|
width: 24.0,
|
|
|
|
height: 24.0,
|
2020-01-04 19:31:52 +00:00
|
|
|
decoration: BoxDecoration(
|
2020-05-21 18:01:12 +00:00
|
|
|
color: Colors.white,
|
|
|
|
shape: BoxShape.circle),
|
2020-01-04 19:31:52 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2020-01-08 12:26:34 +00:00
|
|
|
}
|