mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-01 07:04:08 +01:00
Upstream reformatted its whole tree in 16ddc0837. Matching it removes
formatting from the conflict surface of this and every later sync.
47 lines
1.4 KiB
Dart
47 lines
1.4 KiB
Dart
import 'dart:io';
|
|
import 'package:hash_wallet/main.dart';
|
|
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: navigatorKey.currentState!.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,
|
|
),
|
|
);
|
|
});
|
|
return date;
|
|
}
|