1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
| import 'package:flutter/material.dart'; import 'package:flutter_picker/Picker.dart'; import 'package:get/get.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
import '../index.dart';
class ActionBottomSheet { static Widget _buildHeader({ String? title,
Function()? onConfirm, }) { return <Widget>[ TextWidget.title2(title ?? '').expanded(),
ButtonWidget.text( LocaleKeys.commonBottomApply.tr, onTap: onConfirm, ), ].toRow().padding( left: 10, top: 10, right: 10, ); }
static void data({ required BuildContext context,
required Function(List value) onConfirm,
required PickerAdapter adapter,
String? title,
List<int>? selecteds, }) { var picker = ActionPicker.array( adapter: adapter, selecteds: selecteds, );
normal( context: context, contentPadding: const EdgeInsets.all(0), child: <Widget>[ _buildHeader( title: title, onConfirm: () { picker.doConfirm(context); onConfirm(picker.adapter.getSelectedValues()); }, ), picker.makePicker(), ].toColumn( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, ), ); }
static Future<void> normal({ required BuildContext context, Widget? child, EdgeInsetsGeometry? contentPadding, bool enableDrag = true, }) async { return await showMaterialModalBottomSheet( context: context, backgroundColor: Colors.transparent, enableDrag: enableDrag, builder: (context) => SafeArea( minimum: const EdgeInsets.all(10), child: AnimatedPadding( padding: MediaQuery.of(context).viewInsets, duration: const Duration(milliseconds: 150), child: Container( padding: contentPadding ?? const EdgeInsets.all(10), clipBehavior: Clip.antiAlias, decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20)), ), child: child, ), ), ), ); }
static Future<void> barModel( Widget child, { BuildContext? context, double? padding, bool enableDrag = true, }) async { return await showBarModalBottomSheet( context: context ?? Get.context!, backgroundColor: Colors.transparent, enableDrag: enableDrag, expand: false, builder: (context) => SafeArea( child: child, ), ); }
static Future<void> popModal({ BuildContext? context, required Widget child, EdgeInsetsGeometry? contentPadding, EdgeInsets? safeAreaMinimum, }) async { return await showMaterialModalBottomSheet( context: context ?? Get.context!, backgroundColor: Colors.transparent, builder: (context) => SafeArea( minimum: safeAreaMinimum ?? EdgeInsets.zero, child: child, ), ); } }
|