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.
77 lines
2.4 KiB
Dart
77 lines
2.4 KiB
Dart
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hmg_nurses/generated/locale_keys.g.dart';
|
|
import 'package:sizer/sizer.dart';
|
|
|
|
class CustomCupertinoPicker {
|
|
static TextStyle textStyle(context) => TextStyle(color: Colors.black);
|
|
|
|
static int cupertinoPickerIndex = 0;
|
|
|
|
static buildPickerItems(context, List items, onSelectFun) {
|
|
return CupertinoPicker(
|
|
magnification: 1.5,
|
|
scrollController: FixedExtentScrollController(initialItem: cupertinoPickerIndex),
|
|
itemExtent: 25,
|
|
looping: false,
|
|
onSelectedItemChanged: (int index) {
|
|
cupertinoPickerIndex = index;
|
|
},
|
|
children: items.map((item) {
|
|
return Text(
|
|
'${item.facilityName}',
|
|
style: TextStyle(fontSize: 12.sp, color: Colors.black),
|
|
);
|
|
}).toList(),
|
|
);
|
|
}
|
|
|
|
static showCupertinoPicker(context, List items, onSelectFun) {
|
|
showModalBottomSheet(
|
|
isDismissible: false,
|
|
context: context,
|
|
builder: (BuildContext builder) {
|
|
return Container(
|
|
height: 40.h,
|
|
color: const Color(0xfff7f7f7),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Container(
|
|
color: const Color(0xfff7f7f7),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: <Widget>[
|
|
CupertinoButton(
|
|
child: Text(LocaleKeys.cancel.tr(), style: textStyle(context)),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
CupertinoButton(
|
|
child: Text(
|
|
LocaleKeys.select.tr(),
|
|
style: textStyle(context),
|
|
),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
onSelectFun(cupertinoPickerIndex);
|
|
},
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
height: 30.h,
|
|
color: const Color(0xfff7f7f7),
|
|
child: buildPickerItems(context, items, onSelectFun),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|