mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-02 19:26:27 +00:00
CAKE-97 | created date_picker for Android and iOS; applied date picker to blockchain_height_widget
This commit is contained in:
parent
f5707e6610
commit
ae6291179e
4 changed files with 61 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
|||
import 'package:cake_wallet/utils/date_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
@ -88,7 +89,7 @@ class BlockchainHeightState extends State<BlockchainHeightWidget> {
|
|||
|
||||
Future _selectDate(BuildContext context) async {
|
||||
final now = DateTime.now();
|
||||
final date = await showDatePicker(
|
||||
final date = await getDate(
|
||||
context: context,
|
||||
initialDate: now.subtract(Duration(days: 1)),
|
||||
firstDate: DateTime(2014, DateTime.april),
|
||||
|
|
54
lib/utils/date_picker.dart
Normal file
54
lib/utils/date_picker.dart
Normal file
|
@ -0,0 +1,54 @@
|
|||
import 'dart:io';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<DateTime> getDate({
|
||||
@required BuildContext context,
|
||||
@required DateTime initialDate,
|
||||
@required DateTime firstDate,
|
||||
@required DateTime lastDate}) {
|
||||
|
||||
if (Platform.isIOS) {
|
||||
return _buildCupertinoDataPicker(context, initialDate, firstDate, lastDate);
|
||||
}
|
||||
|
||||
return _buildMaterialDataPicker(context, initialDate, firstDate, lastDate);
|
||||
}
|
||||
|
||||
Future<DateTime> _buildMaterialDataPicker(
|
||||
BuildContext context,
|
||||
DateTime initialDate,
|
||||
DateTime firstDate,
|
||||
DateTime lastDate) async {
|
||||
return await showDatePicker(
|
||||
context: context,
|
||||
initialDate: initialDate,
|
||||
firstDate: firstDate,
|
||||
lastDate: lastDate,
|
||||
helpText: '');
|
||||
}
|
||||
|
||||
Future<DateTime> _buildCupertinoDataPicker(
|
||||
BuildContext context,
|
||||
DateTime initialDate,
|
||||
DateTime firstDate,
|
||||
DateTime lastDate) async {
|
||||
DateTime date;
|
||||
await showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height / 3,
|
||||
child: CupertinoDatePicker(
|
||||
mode: CupertinoDatePickerMode.date,
|
||||
onDateTimeChanged: (picked) => date = picked,
|
||||
initialDateTime: initialDate,
|
||||
minimumDate: firstDate,
|
||||
maximumDate: lastDate,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
return date;
|
||||
}
|
|
@ -14,8 +14,8 @@ Future<T> showPopUp<T>({
|
|||
context: context,
|
||||
builder: builder,
|
||||
barrierDismissible: barrierDismissible,
|
||||
//barrierColor: barrierColor,
|
||||
//useSafeArea: useSafeArea,
|
||||
barrierColor: barrierColor,
|
||||
useSafeArea: useSafeArea,
|
||||
useRootNavigator: useRootNavigator,
|
||||
routeSettings: routeSettings,
|
||||
child: child);
|
||||
|
|
|
@ -589,7 +589,7 @@ packages:
|
|||
name: mobx_codegen
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0+1"
|
||||
version: "1.1.0+2"
|
||||
node_interop:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -708,7 +708,7 @@ packages:
|
|||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.0.3"
|
||||
pointycastle:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1030,5 +1030,5 @@ packages:
|
|||
source: hosted
|
||||
version: "2.2.1"
|
||||
sdks:
|
||||
dart: ">=2.7.0 <3.0.0"
|
||||
dart: ">=2.7.2 <3.0.0"
|
||||
flutter: ">=1.12.13+hotfix.5 <2.0.0"
|
||||
|
|
Loading…
Reference in a new issue