|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_export.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
|
|
|
import 'dart:ui' as ui;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ScrollWheelTimePicker extends StatefulWidget {
|
|
|
|
|
@ -87,97 +88,99 @@ class _ScrollWheelTimePickerState extends State<ScrollWheelTimePicker> {
|
|
|
|
|
final digitStyle = widget.digitTextStyle ?? _defaultDigitStyle;
|
|
|
|
|
final separatorStyle = widget.separatorTextStyle ?? _defaultSeparatorStyle;
|
|
|
|
|
|
|
|
|
|
return SizedBox(
|
|
|
|
|
height: widget.pickerHeight,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 150.w,
|
|
|
|
|
child: ListWheelScrollView.useDelegate(
|
|
|
|
|
controller: _hourController,
|
|
|
|
|
itemExtent: widget.itemExtent,
|
|
|
|
|
physics: const FixedExtentScrollPhysics(),
|
|
|
|
|
perspective: 0.005,
|
|
|
|
|
diameterRatio: 1.2,
|
|
|
|
|
onSelectedItemChanged: (index) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedHour =
|
|
|
|
|
widget.use24HourFormat ? index : index + 1;
|
|
|
|
|
});
|
|
|
|
|
_notifyChange();
|
|
|
|
|
},
|
|
|
|
|
childDelegate: ListWheelChildBuilderDelegate(
|
|
|
|
|
childCount: _maxHour,
|
|
|
|
|
builder: (context, index) {
|
|
|
|
|
final hour =
|
|
|
|
|
widget.use24HourFormat ? index : index + 1;
|
|
|
|
|
final isSelected = hour == _selectedHour;
|
|
|
|
|
return Visibility(
|
|
|
|
|
visible: true,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: AnimatedDefaultTextStyle(
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
style: digitStyle.copyWith(
|
|
|
|
|
color: isSelected
|
|
|
|
|
? AppColors.textColor
|
|
|
|
|
: AppColors.textColor.withValues(alpha: 0.3),
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
hour.toString().padLeft(2, '0'),
|
|
|
|
|
return Directionality(
|
|
|
|
|
textDirection: ui.TextDirection.ltr,
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
height: widget.pickerHeight,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 150.w,
|
|
|
|
|
child: ListWheelScrollView.useDelegate(
|
|
|
|
|
controller: _hourController,
|
|
|
|
|
itemExtent: widget.itemExtent,
|
|
|
|
|
physics: const FixedExtentScrollPhysics(),
|
|
|
|
|
perspective: 0.005,
|
|
|
|
|
diameterRatio: 1.2,
|
|
|
|
|
onSelectedItemChanged: (index) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedHour =
|
|
|
|
|
widget.use24HourFormat ? index : index + 1;
|
|
|
|
|
});
|
|
|
|
|
_notifyChange();
|
|
|
|
|
},
|
|
|
|
|
childDelegate: ListWheelChildBuilderDelegate(
|
|
|
|
|
childCount: _maxHour,
|
|
|
|
|
builder: (context, index) {
|
|
|
|
|
final hour =
|
|
|
|
|
widget.use24HourFormat ? index : index + 1;
|
|
|
|
|
final isSelected = hour == _selectedHour;
|
|
|
|
|
return Visibility(
|
|
|
|
|
visible: true,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: AnimatedDefaultTextStyle(
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
style: digitStyle.copyWith(
|
|
|
|
|
color: isSelected
|
|
|
|
|
? AppColors.textColor
|
|
|
|
|
: AppColors.textColor.withValues(alpha: 0.3),
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
hour.toString().padLeft(2, '0'),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 2.w),
|
|
|
|
|
child: Text(':', style: separatorStyle),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 150.w,
|
|
|
|
|
child: ListWheelScrollView.useDelegate(
|
|
|
|
|
controller: _minuteController,
|
|
|
|
|
itemExtent: widget.itemExtent,
|
|
|
|
|
physics: const FixedExtentScrollPhysics(),
|
|
|
|
|
perspective: 0.005,
|
|
|
|
|
diameterRatio: 1.2,
|
|
|
|
|
onSelectedItemChanged: (index) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedMinute = index;
|
|
|
|
|
});
|
|
|
|
|
_notifyChange();
|
|
|
|
|
},
|
|
|
|
|
childDelegate: ListWheelChildBuilderDelegate(
|
|
|
|
|
childCount: 60,
|
|
|
|
|
|
|
|
|
|
builder: (context, index) {
|
|
|
|
|
final isSelected = index == _selectedMinute;
|
|
|
|
|
return Visibility(
|
|
|
|
|
visible: true,
|
|
|
|
|
child:
|
|
|
|
|
Center(
|
|
|
|
|
child: AnimatedDefaultTextStyle(
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
style: digitStyle.copyWith(
|
|
|
|
|
color: isSelected
|
|
|
|
|
? AppColors.textColor
|
|
|
|
|
: AppColors.transparent.withValues(alpha: 0.3),
|
|
|
|
|
),
|
|
|
|
|
child: Text(index.toString().padLeft(2, '0')),
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 2.w),
|
|
|
|
|
child: Text(':', style: separatorStyle),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 150.w,
|
|
|
|
|
child: ListWheelScrollView.useDelegate(
|
|
|
|
|
controller: _minuteController,
|
|
|
|
|
itemExtent: widget.itemExtent,
|
|
|
|
|
physics: const FixedExtentScrollPhysics(),
|
|
|
|
|
perspective: 0.005,
|
|
|
|
|
diameterRatio: 1.2,
|
|
|
|
|
onSelectedItemChanged: (index) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedMinute = index;
|
|
|
|
|
});
|
|
|
|
|
_notifyChange();
|
|
|
|
|
},
|
|
|
|
|
childDelegate: ListWheelChildBuilderDelegate(
|
|
|
|
|
childCount: 60,
|
|
|
|
|
builder: (context, index) {
|
|
|
|
|
final isSelected = index == _selectedMinute;
|
|
|
|
|
return Visibility(
|
|
|
|
|
visible: true,
|
|
|
|
|
child:
|
|
|
|
|
Center(
|
|
|
|
|
child: AnimatedDefaultTextStyle(
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
style: digitStyle.copyWith(
|
|
|
|
|
color: isSelected
|
|
|
|
|
? AppColors.textColor
|
|
|
|
|
: AppColors.transparent.withValues(alpha: 0.3),
|
|
|
|
|
),
|
|
|
|
|
child: Text(index.toString().padLeft(2, '0')),
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|