From 9ff14ea4711c36b394b2fe1384453f583a7d06cb Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 8 May 2024 10:53:47 -0600 Subject: [PATCH] remove old date picker leftovers --- lib/widgets/rounded_date_picker/LICENSE | 5 - .../flutter_rounded_date_picker_dialog.dart | 342 ------------------ .../flutter_rounded_date_picker_widget.dart | 226 ------------ 3 files changed, 573 deletions(-) delete mode 100644 lib/widgets/rounded_date_picker/LICENSE delete mode 100644 lib/widgets/rounded_date_picker/flutter_rounded_date_picker_dialog.dart delete mode 100644 lib/widgets/rounded_date_picker/flutter_rounded_date_picker_widget.dart diff --git a/lib/widgets/rounded_date_picker/LICENSE b/lib/widgets/rounded_date_picker/LICENSE deleted file mode 100644 index 58665fbd2..000000000 --- a/lib/widgets/rounded_date_picker/LICENSE +++ /dev/null @@ -1,5 +0,0 @@ -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at: - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. \ No newline at end of file diff --git a/lib/widgets/rounded_date_picker/flutter_rounded_date_picker_dialog.dart b/lib/widgets/rounded_date_picker/flutter_rounded_date_picker_dialog.dart deleted file mode 100644 index 3c8ff39bb..000000000 --- a/lib/widgets/rounded_date_picker/flutter_rounded_date_picker_dialog.dart +++ /dev/null @@ -1,342 +0,0 @@ -/* - * This file is part of Stack Wallet. - * - * Copyright (c) 2023 Cypher Stack - * All Rights Reserved. - * The code is distributed under GPLv3 license, see LICENSE file for details. - * Generated by Cypher Stack on 2023-05-26 - * - */ - -import 'package:flutter/material.dart'; -import 'package:flutter/semantics.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_rounded_date_picker/flutter_rounded_date_picker.dart'; -import 'package:flutter_rounded_date_picker/src/flutter_rounded_button_action.dart'; -import 'package:flutter_rounded_date_picker/src/material_rounded_date_picker_style.dart'; -import 'package:flutter_rounded_date_picker/src/material_rounded_year_picker_style.dart'; -import 'package:flutter_rounded_date_picker/src/widgets/flutter_rounded_date_picker_header.dart'; -import 'package:flutter_rounded_date_picker/src/widgets/flutter_rounded_day_picker.dart'; -import 'package:flutter_rounded_date_picker/src/widgets/flutter_rounded_month_picker.dart'; -import 'package:flutter_rounded_date_picker/src/widgets/flutter_rounded_year_picker.dart'; -import 'package:stackwallet/utilities/util.dart'; - -/// -/// This file uses code taken from https://github.com/benznest/flutter_rounded_date_picker -/// - -class FlutterRoundedDatePickerDialog extends StatefulWidget { - const FlutterRoundedDatePickerDialog( - {Key? key, - this.height, - required this.initialDate, - required this.firstDate, - required this.lastDate, - this.selectableDayPredicate, - required this.initialDatePickerMode, - required this.era, - this.locale, - required this.borderRadius, - this.imageHeader, - this.description = "", - this.fontFamily, - this.textNegativeButton, - this.textPositiveButton, - this.textActionButton, - this.onTapActionButton, - this.styleDatePicker, - this.styleYearPicker, - this.customWeekDays, - this.builderDay, - this.listDateDisabled, - this.onTapDay, - this.onMonthChange}) - : super(key: key); - - final DateTime initialDate; - final DateTime firstDate; - final DateTime lastDate; - final SelectableDayPredicate? selectableDayPredicate; - final DatePickerMode initialDatePickerMode; - - /// double height. - final double? height; - - /// Custom era year. - final EraMode era; - final Locale? locale; - - /// Border - final double borderRadius; - - /// Header; - final ImageProvider? imageHeader; - final String description; - - /// Font - final String? fontFamily; - - /// Button - final String? textNegativeButton; - final String? textPositiveButton; - final String? textActionButton; - - final VoidCallback? onTapActionButton; - - /// Style - final MaterialRoundedDatePickerStyle? styleDatePicker; - final MaterialRoundedYearPickerStyle? styleYearPicker; - - /// Custom Weekday - final List? customWeekDays; - - final BuilderDayOfDatePicker? builderDay; - - final List? listDateDisabled; - final OnTapDay? onTapDay; - - final Function? onMonthChange; - - @override - _FlutterRoundedDatePickerDialogState createState() => - _FlutterRoundedDatePickerDialogState(); -} - -class _FlutterRoundedDatePickerDialogState - extends State { - @override - void initState() { - super.initState(); - _selectedDate = widget.initialDate; - _mode = widget.initialDatePickerMode; - } - - bool _announcedInitialDate = false; - - late MaterialLocalizations localizations; - late TextDirection textDirection; - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - localizations = MaterialLocalizations.of(context); - textDirection = Directionality.of(context); - if (!_announcedInitialDate) { - _announcedInitialDate = true; - SemanticsService.announce( - localizations.formatFullDate(_selectedDate), - textDirection, - ); - } - } - - late DateTime _selectedDate; - late DatePickerMode _mode; - final GlobalKey _pickerKey = GlobalKey(); - - void _vibrate() { - switch (Theme.of(context).platform) { - case TargetPlatform.android: - case TargetPlatform.fuchsia: - HapticFeedback.vibrate(); - break; - case TargetPlatform.iOS: - default: - break; - } - } - - void _handleModeChanged(DatePickerMode mode) { - _vibrate(); - setState(() { - _mode = mode; - if (_mode == DatePickerMode.day) { - SemanticsService.announce( - localizations.formatMonthYear(_selectedDate), - textDirection, - ); - } else { - SemanticsService.announce( - localizations.formatYear(_selectedDate), - textDirection, - ); - } - }); - } - - Future _handleYearChanged(DateTime value) async { - if (value.isBefore(widget.firstDate)) { - value = widget.firstDate; - } else if (value.isAfter(widget.lastDate)) { - value = widget.lastDate; - } - if (value == _selectedDate) return; - - if (widget.onMonthChange != null) await widget.onMonthChange!(value); - - _vibrate(); - setState(() { - _mode = DatePickerMode.day; - _selectedDate = value; - }); - } - - void _handleDayChanged(DateTime value) { - _vibrate(); - setState(() { - _selectedDate = value; - }); - } - - void _handleCancel() { - Navigator.of(context).pop(); - } - - void _handleOk() { - Navigator.of(context).pop(_selectedDate); - } - - Widget _buildPicker() { - switch (_mode) { - case DatePickerMode.year: - return FlutterRoundedYearPicker( - key: _pickerKey, - selectedDate: _selectedDate, - onChanged: (DateTime date) async => await _handleYearChanged(date), - firstDate: widget.firstDate, - lastDate: widget.lastDate, - era: widget.era, - fontFamily: widget.fontFamily, - style: widget.styleYearPicker, - ); - case DatePickerMode.day: - default: - return FlutterRoundedMonthPicker( - key: _pickerKey, - selectedDate: _selectedDate, - onChanged: _handleDayChanged, - firstDate: widget.firstDate, - lastDate: widget.lastDate, - era: widget.era, - locale: widget.locale, - selectableDayPredicate: widget.selectableDayPredicate, - fontFamily: widget.fontFamily, - style: widget.styleDatePicker, - borderRadius: widget.borderRadius, - customWeekDays: widget.customWeekDays, - builderDay: widget.builderDay, - listDateDisabled: widget.listDateDisabled, - onTapDay: widget.onTapDay, - onMonthChange: widget.onMonthChange); - } - } - - @override - Widget build(BuildContext context) { - final ThemeData theme = Theme.of(context); - final Widget picker = _buildPicker(); - final isDesktop = Util.isDesktop; - - final Widget actions = FlutterRoundedButtonAction( - textButtonNegative: widget.textNegativeButton, - textButtonPositive: widget.textPositiveButton, - onTapButtonNegative: _handleCancel, - onTapButtonPositive: _handleOk, - textActionButton: widget.textActionButton, - onTapButtonAction: widget.onTapActionButton, - localizations: localizations, - textStyleButtonNegative: widget.styleDatePicker?.textStyleButtonNegative, - textStyleButtonPositive: widget.styleDatePicker?.textStyleButtonPositive, - textStyleButtonAction: widget.styleDatePicker?.textStyleButtonAction, - borderRadius: widget.borderRadius, - paddingActionBar: widget.styleDatePicker?.paddingActionBar, - background: widget.styleDatePicker?.backgroundActionBar, - ); - - Color backgroundPicker = theme.dialogBackgroundColor; - if (_mode == DatePickerMode.day) { - backgroundPicker = widget.styleDatePicker?.backgroundPicker ?? - theme.dialogBackgroundColor; - } else { - backgroundPicker = widget.styleYearPicker?.backgroundPicker ?? - theme.dialogBackgroundColor; - } - - final Dialog dialog = Dialog( - child: OrientationBuilder( - builder: (BuildContext context, Orientation orientation) { - final Widget header = FlutterRoundedDatePickerHeader( - selectedDate: _selectedDate, - mode: _mode, - onModeChanged: _handleModeChanged, - orientation: orientation, - era: widget.era, - borderRadius: widget.borderRadius, - imageHeader: widget.imageHeader, - description: widget.description, - fontFamily: widget.fontFamily, - style: widget.styleDatePicker); - switch (orientation) { - case Orientation.landscape: - return Container( - height: isDesktop ? 600 : null, - width: isDesktop ? 700 : null, - decoration: BoxDecoration( - color: backgroundPicker, - borderRadius: BorderRadius.circular(widget.borderRadius), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Flexible(flex: 1, child: header), - Flexible( - flex: 2, // have the picker take up 2/3 of the dialog width - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SizedBox( - height: isDesktop ? 530 : null, - width: isDesktop ? 700 : null, - child: picker), - actions, - ], - ), - ), - ], - ), - ); - case Orientation.portrait: - default: - return Container( - decoration: BoxDecoration( - color: backgroundPicker, - borderRadius: BorderRadius.circular(widget.borderRadius), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - header, - if (widget.height == null) - Flexible(child: picker) - else - SizedBox( - height: widget.height, - child: picker, - ), - actions, - ], - ), - ); - } - }), - ); - - return Theme( - data: theme.copyWith(dialogBackgroundColor: Colors.transparent), - child: dialog, - ); - } -} diff --git a/lib/widgets/rounded_date_picker/flutter_rounded_date_picker_widget.dart b/lib/widgets/rounded_date_picker/flutter_rounded_date_picker_widget.dart deleted file mode 100644 index 6f6db0580..000000000 --- a/lib/widgets/rounded_date_picker/flutter_rounded_date_picker_widget.dart +++ /dev/null @@ -1,226 +0,0 @@ -/* - * This file is part of Stack Wallet. - * - * Copyright (c) 2023 Cypher Stack - * All Rights Reserved. - * The code is distributed under GPLv3 license, see LICENSE file for details. - * Generated by Cypher Stack on 2023-05-26 - * - */ - -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; - -import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; -// import 'package:flutter_rounded_date_picker/src/dialogs/flutter_rounded_date_picker_dialog.dart'; -import 'package:flutter_rounded_date_picker/src/era_mode.dart'; -import 'package:flutter_rounded_date_picker/src/material_rounded_date_picker_style.dart'; -import 'package:flutter_rounded_date_picker/src/material_rounded_year_picker_style.dart'; -import 'package:flutter_rounded_date_picker/src/widgets/flutter_rounded_day_picker.dart'; -import 'package:stackwallet/widgets/rounded_date_picker/flutter_rounded_date_picker_dialog.dart'; - -/// -/// This file uses code taken from https://github.com/benznest/flutter_rounded_date_picker -/// - -// Examples can assume: -// BuildContext context; - -/// Initial display mode of the date picker dialog. -/// -/// Date picker UI mode for either showing a list of available years or a -/// monthly calendar initially in the dialog shown by calling [showDatePicker]. -/// - -// Shows the selected date in large font and toggles between year and day mode - -/// Signature for predicating dates for enabled date selections. -/// -/// See [showDatePicker]. -typedef SelectableDayPredicate = bool Function(DateTime day); - -/// Shows a dialog containing a material design date picker. -/// -/// The returned [Future] resolves to the date selected by the user when the -/// user closes the dialog. If the user cancels the dialog, null is returned. -/// -/// An optional [selectableDayPredicate] function can be passed in to customize -/// the days to enable for selection. If provided, only the days that -/// [selectableDayPredicate] returned true for will be selectable. -/// -/// An optional [initialDatePickerMode] argument can be used to display the -/// date picker initially in the year or month+day picker mode. It defaults -/// to month+day, and must not be null. -/// -/// An optional [locale] argument can be used to set the locale for the date -/// picker. It defaults to the ambient locale provided by [Localizations]. -/// -/// An optional [textDirection] argument can be used to set the text direction -/// (RTL or LTR) for the date picker. It defaults to the ambient text direction -/// provided by [Directionality]. If both [locale] and [textDirection] are not -/// null, [textDirection] overrides the direction chosen for the [locale]. -/// -/// The [context] argument is passed to [showDialog], the documentation for -/// which discusses how it is used. -/// -/// The [builder] parameter can be used to wrap the dialog widget -/// to add inherited widgets like [Theme]. -/// -/// {@tool sample} -/// Show a date picker with the dark theme. -/// -/// ```dart -/// Future selectedDate = showDatePicker( -/// context: context, -/// initialDate: DateTime.now(), -/// firstDate: DateTime(2018), -/// lastDate: DateTime(2030), -/// builder: (BuildContext context, Widget child) { -/// return Theme( -/// data: ThemeData.dark(), -/// child: child, -/// ); -/// }, -/// ); -/// ``` -/// {@end-tool} -/// -/// The [context], [initialDate], [firstDate], and [lastDate] parameters must -/// not be null. -/// -/// See also: -/// -/// * [showTimePicker], which shows a dialog that contains a material design -/// time picker. -/// * [DayPicker], which displays the days of a given month and allows -/// choosing a day. -/// * [MonthPicker], which displays a scrollable list of months to allow -/// picking a month. -/// * [YearPicker], which displays a scrollable list of years to allow picking -/// a year. -/// - -Future showRoundedDatePicker( - {required BuildContext context, - double? height, - DateTime? initialDate, - DateTime? firstDate, - DateTime? lastDate, - SelectableDayPredicate? selectableDayPredicate, - DatePickerMode initialDatePickerMode = DatePickerMode.day, - Locale? locale, - TextDirection? textDirection, - ThemeData? theme, - double borderRadius = 16, - EraMode era = EraMode.CHRIST_YEAR, - ImageProvider? imageHeader, - String description = "", - String? fontFamily, - bool barrierDismissible = false, - Color background = Colors.transparent, - String? textNegativeButton, - String? textPositiveButton, - String? textActionButton, - VoidCallback? onTapActionButton, - MaterialRoundedDatePickerStyle? styleDatePicker, - MaterialRoundedYearPickerStyle? styleYearPicker, - List? customWeekDays, - BuilderDayOfDatePicker? builderDay, - List? listDateDisabled, - OnTapDay? onTapDay, - Function? onMonthChange}) async { - initialDate ??= DateTime.now(); - firstDate ??= DateTime(initialDate.year - 1); - lastDate ??= DateTime(initialDate.year + 1); - theme ??= ThemeData(); - - assert( - !initialDate.isBefore(firstDate), - 'initialDate must be on or after firstDate', - ); - assert( - !initialDate.isAfter(lastDate), - 'initialDate must be on or before lastDate', - ); - assert( - !firstDate.isAfter(lastDate), - 'lastDate must be on or after firstDate', - ); - assert( - selectableDayPredicate == null || selectableDayPredicate(initialDate), - 'Provided initialDate must satisfy provided selectableDayPredicate', - ); - assert( - (onTapActionButton != null && textActionButton != null) || - onTapActionButton == null, - "If you provide onLeftBtn, you must provide leftBtn", - ); - assert(debugCheckHasMaterialLocalizations(context)); - - Widget child = GestureDetector( - onTap: () { - if (!barrierDismissible) { - Navigator.pop(context); - } - }, - child: Container( - color: background, - child: GestureDetector( - onTap: () { - // - }, - child: FlutterRoundedDatePickerDialog( - height: height, - initialDate: initialDate, - firstDate: firstDate, - lastDate: lastDate, - selectableDayPredicate: selectableDayPredicate, - initialDatePickerMode: initialDatePickerMode, - era: era, - locale: locale, - borderRadius: borderRadius, - imageHeader: imageHeader, - description: description, - fontFamily: fontFamily, - textNegativeButton: textNegativeButton, - textPositiveButton: textPositiveButton, - textActionButton: textActionButton, - onTapActionButton: onTapActionButton, - styleDatePicker: styleDatePicker, - styleYearPicker: styleYearPicker, - customWeekDays: customWeekDays, - builderDay: builderDay, - listDateDisabled: listDateDisabled, - onTapDay: onTapDay, - onMonthChange: onMonthChange, - ), - ), - ), - ); - - if (textDirection != null) { - child = Directionality( - textDirection: textDirection, - child: child, - ); - } - - if (locale != null) { - child = Localizations.override( - context: context, - locale: locale, - child: child, - ); - } - - return await showDialog( - context: context, - barrierDismissible: barrierDismissible, - builder: (_) => Theme(data: theme!, child: child), - ); -}