You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App_New/lib/presentation/prescriptions/prescription_reminder_view....

117 lines
3.9 KiB
Dart

import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_export.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
class PrescriptionReminderView extends StatefulWidget {
Function(int) setReminder;
PrescriptionReminderView({Key? key, required this.setReminder}) : super(key: key);
@override
_PrescriptionReminderViewState createState() {
return _PrescriptionReminderViewState();
}
}
class _PrescriptionReminderViewState extends State<PrescriptionReminderView> {
final List<int> _options = [15, 30, 60, 90];
int _selectedOption = 0; // Nullable to represent no selection initially
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
spacing: 16.h,
children: [
Container(
width: double.infinity,
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24),
child: ListView.builder(
itemCount: _options.length,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.only(top: 8, bottom: 8),
shrinkWrap: true,
itemBuilder: (context, index) {
return Theme(
data: Theme.of(context).copyWith(
listTileTheme: ListTileThemeData(horizontalTitleGap: 4),
),
child: RadioListTile<int>(
title: Text(
"${_options[index]} minutes before".needTranslation,
style: TextStyle(
fontSize: 16.h,
fontWeight: FontWeight.w500,
),
),
value: index,
fillColor: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.selected)) {
return AppColors.primaryRedColor;
}
return Color(0xffEEEEEE);
}),
contentPadding: EdgeInsets.only(left: 12.h, right: 12.h),
groupValue: _selectedOption,
onChanged: (int? newValue) {
setState(() {
_selectedOption = newValue!;
});
},
),
);
},
),
),
Row(
spacing: 16.h,
children: [
Expanded(
child: CustomButton(
text: LocaleKeys.cancel.tr(),
onPressed: () {
Navigator.of(context).pop();
},
backgroundColor: AppColors.secondaryLightRedColor,
borderColor: AppColors.secondaryLightRedColor,
textColor: AppColors.primaryRedColor,
icon: AppAssets.cancel,
iconColor: AppColors.primaryRedColor,
),
),
Expanded(
child: CustomButton(
text: LocaleKeys.setReminder.tr(),
onPressed: () {
Navigator.of(context).pop();
widget.setReminder(_selectedOption);
},
backgroundColor: AppColors.bgGreenColor,
borderColor: AppColors.bgGreenColor,
textColor: Colors.white,
icon: AppAssets.reminder_bell,
),
),
],
),
],
);
}
}