mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
55 lines
1.4 KiB
Dart
55 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:syncrow_app/generated/assets.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
|
|
class LightSwitch extends StatefulWidget {
|
|
const LightSwitch({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
State<LightSwitch> createState() => _LightSwitchState();
|
|
}
|
|
|
|
class _LightSwitchState extends State<LightSwitch> {
|
|
bool isOn = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
overlayColor: MaterialStateProperty.all(Colors.transparent),
|
|
onTap: () {
|
|
setState(() {
|
|
isOn = !isOn;
|
|
});
|
|
},
|
|
child: Stack(
|
|
alignment: isOn ? Alignment.topCenter : Alignment.bottomCenter,
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: const BorderRadius.all(Radius.circular(100.0)),
|
|
color: isOn
|
|
? ColorsManager.primaryColorWithOpacity
|
|
: ColorsManager.switchOffColor,
|
|
),
|
|
width: 60,
|
|
height: 115,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(5.0),
|
|
child: SizedBox.square(
|
|
dimension: 60,
|
|
child: SvgPicture.asset(
|
|
isOn ? Assets.iconsLightSwitchOn : Assets.iconsLightSwitchOff,
|
|
fit: BoxFit.fill,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|