mirror of
https://github.com/stonega/tsacdop
synced 2025-01-05 19:47:56 +01:00
Change time picker style.
This commit is contained in:
parent
7bbeee5f34
commit
99cf220adc
@ -2,9 +2,7 @@ import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_time_picker_spinner/flutter_time_picker_spinner.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
@ -12,8 +10,8 @@ import '../home/audioplayer.dart';
|
||||
import '../state/audio_state.dart';
|
||||
import '../state/setting_state.dart';
|
||||
import '../util/custom_dropdown.dart';
|
||||
import '../util/custom_time_picker.dart';
|
||||
import '../util/extension_helper.dart';
|
||||
import '../util/general_dialog.dart';
|
||||
|
||||
const List secondsToSelect = [10, 15, 20, 25, 30, 45, 60];
|
||||
|
||||
@ -105,54 +103,26 @@ class PlaySetting extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
var startTime = data.item1;
|
||||
generalDialog(
|
||||
context,
|
||||
content: TimePickerSpinner(
|
||||
minutesInterval: 15,
|
||||
time: DateTime.fromMillisecondsSinceEpoch(
|
||||
data.item1 * 60 * 1000,
|
||||
isUtc: true),
|
||||
isForce2Digits: true,
|
||||
is24HourMode: false,
|
||||
highlightedTextStyle: GoogleFonts.teko(
|
||||
textStyle: TextStyle(
|
||||
fontSize: 40, color: context.accentColor)),
|
||||
normalTextStyle: GoogleFonts.teko(
|
||||
textStyle:
|
||||
TextStyle(fontSize: 40, color: Colors.black38)),
|
||||
onTimeChange: (time) {
|
||||
startTime = time.hour * 60 + time.minute;
|
||||
},
|
||||
),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(
|
||||
s.cancel,
|
||||
style: TextStyle(color: Colors.grey[600]),
|
||||
),
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
if (startTime != data.item2) {
|
||||
settings.setAutoSleepTimerStart = startTime;
|
||||
Navigator.of(context).pop();
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastTimeEqualEnd,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
s.confirm,
|
||||
style: TextStyle(color: context.accentColor),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
final timeOfDay = await showCustomTimePicker(
|
||||
context: context,
|
||||
cancelText: s.cancel,
|
||||
confirmText: s.confirm,
|
||||
helpText: '',
|
||||
initialTime: TimeOfDay(
|
||||
hour: startTime ~/ 60, minute: startTime % 60));
|
||||
if (timeOfDay != null) {
|
||||
startTime = timeOfDay.hour * 60 + timeOfDay.minute;
|
||||
if (startTime != data.item2) {
|
||||
settings.setAutoSleepTimerStart = startTime;
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastTimeEqualEnd,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(5), topLeft: Radius.circular(5)),
|
||||
@ -171,54 +141,26 @@ class PlaySetting extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
int endTime;
|
||||
generalDialog(
|
||||
context,
|
||||
content: TimePickerSpinner(
|
||||
minutesInterval: 15,
|
||||
time: DateTime.fromMillisecondsSinceEpoch(
|
||||
data.item2 * 60 * 1000,
|
||||
isUtc: true),
|
||||
isForce2Digits: true,
|
||||
highlightedTextStyle: GoogleFonts.teko(
|
||||
textStyle: TextStyle(
|
||||
fontSize: 40, color: context.accentColor)),
|
||||
normalTextStyle: GoogleFonts.teko(
|
||||
textStyle:
|
||||
TextStyle(fontSize: 40, color: Colors.black38)),
|
||||
is24HourMode: false,
|
||||
onTimeChange: (time) {
|
||||
endTime = time.hour * 60 + time.minute;
|
||||
},
|
||||
),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(
|
||||
s.cancel,
|
||||
style: TextStyle(color: Colors.grey[600]),
|
||||
),
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
if (endTime != data.item1) {
|
||||
settings.setAutoSleepTimerEnd = endTime;
|
||||
Navigator.of(context).pop();
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastTimeEqualStart,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
s.confirm,
|
||||
style: TextStyle(color: context.accentColor),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
onTap: () async {
|
||||
var endTime = data.item2;
|
||||
final timeOfDay = await showCustomTimePicker(
|
||||
context: context,
|
||||
cancelText: s.cancel,
|
||||
confirmText: s.confirm,
|
||||
helpText: '',
|
||||
initialTime:
|
||||
TimeOfDay(hour: endTime ~/ 60, minute: endTime % 60));
|
||||
if (timeOfDay != null) {
|
||||
endTime = timeOfDay.hour * 60 + timeOfDay.minute;
|
||||
if (endTime != data.item1) {
|
||||
settings.setAutoSleepTimerEnd = endTime;
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastTimeEqualStart,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomRight: Radius.circular(5),
|
||||
|
2179
lib/util/custom_time_picker.dart
Normal file
2179
lib/util/custom_time_picker.dart
Normal file
File diff suppressed because it is too large
Load Diff
@ -26,7 +26,6 @@ dependencies:
|
||||
flutter_downloader: ^1.4.4
|
||||
fluttertoast: ^4.0.0
|
||||
flutter_isolate: ^1.0.0+14
|
||||
flutter_time_picker_spinner: ^1.0.6+1
|
||||
flutter_linkify: ^3.1.3
|
||||
flutter_file_dialog: ^0.0.5
|
||||
flare_flutter: ^2.0.6
|
||||
|
Loading…
Reference in New Issue
Block a user