forked from eatvio/eatvio_app
refactor(diary): Refactoring for settings done
This commit is contained in:
55
lib/widgets/custom_hyper_switch.dart
Normal file
55
lib/widgets/custom_hyper_switch.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart';
|
||||
|
||||
class HyperSwitch extends StatefulWidget {
|
||||
final String title;
|
||||
final MyProfileLoadedState? state;
|
||||
HyperSwitch(this.title, this.state);
|
||||
|
||||
@override
|
||||
_HyperState createState() => _HyperState();
|
||||
}
|
||||
|
||||
class _HyperState extends State<HyperSwitch> {
|
||||
bool switchValue = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.state?.hyperFormController == '1') {
|
||||
switchValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.title,
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 14, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Switch(
|
||||
value: switchValue,
|
||||
onChanged: toggleSwitch(),
|
||||
inactiveThumbColor: appTheme.blueA400,
|
||||
inactiveTrackColor: Colors.white,
|
||||
activeTrackColor: appTheme.blueA400,
|
||||
activeColor: Colors.white,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
toggleSwitch() {
|
||||
return (value) {
|
||||
setState(() {
|
||||
switchValue = value;
|
||||
widget.state!.hyperFormController = value ? "1" : "0";
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user