mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 05:57:56 +00:00
222 lines
6.7 KiB
Dart
222 lines
6.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:syncrow_app/features/devices/view/widgets/restart_status_dialog.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
import 'package:syncrow_app/generated/assets.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
class HumidityDialog extends StatefulWidget {
|
|
final String label1;
|
|
final String label2;
|
|
final String label3;
|
|
final String title;
|
|
final Function()? cancelTab;
|
|
final Function(String labelSelected)? confirmTab;
|
|
|
|
final String? initialSelectedLabel;
|
|
|
|
HumidityDialog({
|
|
required this.label1,
|
|
required this.label2,
|
|
required this.label3,
|
|
required this.title,
|
|
required this.cancelTab,
|
|
required this.confirmTab,
|
|
this.initialSelectedLabel,
|
|
});
|
|
|
|
@override
|
|
_HumidityDialogState createState() => _HumidityDialogState();
|
|
}
|
|
|
|
class _HumidityDialogState extends State<HumidityDialog> {
|
|
late String _selectedOption;
|
|
String _selectedCity = 'Current City';
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_selectedOption = widget.initialSelectedLabel ?? '';
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AlertDialog(
|
|
contentPadding: EdgeInsets.zero,
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
const SizedBox(
|
|
height: 10,
|
|
),
|
|
BodyLarge(
|
|
text: widget.title,
|
|
fontWeight: FontWeight.w700,
|
|
fontColor: ColorsManager.primaryColor,
|
|
fontSize: 16,
|
|
),
|
|
const Padding(
|
|
padding: EdgeInsets.only(left: 15, right: 15),
|
|
child: Divider(
|
|
color: ColorsManager.textGray,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 15, right: 15),
|
|
child: Column(
|
|
children: [
|
|
_buildCheckboxOption(
|
|
icon: Assets.dryIcon,
|
|
label: widget.label1,
|
|
onTap: (v) {
|
|
_selectedOption = v;
|
|
},
|
|
),
|
|
_buildCheckboxOption(
|
|
icon: Assets.comfortableIcon,
|
|
label: widget.label2,
|
|
onTap: (v) {
|
|
_selectedOption = v;
|
|
},
|
|
),
|
|
_buildCheckboxOption(
|
|
icon: Assets.moistIcon,
|
|
label: widget.label3,
|
|
onTap: (v) {
|
|
_selectedOption = v;
|
|
},
|
|
),
|
|
Container(
|
|
height: 35,
|
|
child: ElevatedButton(
|
|
onPressed: () {},
|
|
child: Text(
|
|
_selectedCity,
|
|
style: TextStyle(
|
|
color: ColorsManager.grayColor,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400),
|
|
),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: ColorsManager.grayBox.withOpacity(0.6),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 10,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
decoration: const BoxDecoration(
|
|
border: Border(
|
|
right: BorderSide(
|
|
color: ColorsManager.textGray,
|
|
width: 0.5,
|
|
),
|
|
top: BorderSide(
|
|
color: ColorsManager.textGray,
|
|
width: 1.0,
|
|
),
|
|
)),
|
|
child: SizedBox(
|
|
child: InkWell(
|
|
onTap: widget.cancelTab,
|
|
child: const Padding(
|
|
padding: EdgeInsets.all(15),
|
|
child: Center(
|
|
child: Text(
|
|
'Cancel',
|
|
style: TextStyle(
|
|
color: ColorsManager.textGray,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
decoration: const BoxDecoration(
|
|
border: Border(
|
|
left: BorderSide(
|
|
color: ColorsManager.textGray,
|
|
width: 0.5,
|
|
),
|
|
top: BorderSide(
|
|
color: ColorsManager.textGray,
|
|
width: 1.0,
|
|
),
|
|
)),
|
|
child: InkWell(
|
|
onTap: () {
|
|
widget.confirmTab!.call(_selectedCity);
|
|
},
|
|
child: const Padding(
|
|
padding: EdgeInsets.all(15),
|
|
child: Center(
|
|
child: Text(
|
|
'Confirm',
|
|
style: TextStyle(
|
|
color: ColorsManager.primaryColor,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400),
|
|
),
|
|
),
|
|
)),
|
|
))
|
|
],
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildCheckboxOption(
|
|
{required String label, required String icon, Function(String)? onTap}) {
|
|
return Padding(
|
|
padding: const EdgeInsets.only(bottom: 10, top: 10),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
SvgPicture.asset(icon),
|
|
SizedBox(
|
|
width: 15,
|
|
),
|
|
BodyMedium(
|
|
text: label,
|
|
style:
|
|
const TextStyle(fontSize: 15, fontWeight: FontWeight.w400),
|
|
),
|
|
],
|
|
),
|
|
CircularCheckbox(
|
|
value: _selectedOption == label,
|
|
onChanged: (bool? value) {
|
|
if (value == true) {
|
|
setState(() {
|
|
_selectedOption = label;
|
|
});
|
|
if (onTap != null) {
|
|
onTap(label);
|
|
}
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|