Skip to content

Commit

Permalink
Добавлен час в вертушку
Browse files Browse the repository at this point in the history
  • Loading branch information
Isfun committed Aug 9, 2020
1 parent 27f81a0 commit 9ba2601
Show file tree
Hide file tree
Showing 6 changed files with 406 additions and 203 deletions.
75 changes: 75 additions & 0 deletions lib/custom_picker.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';

class CustomPicker extends CommonPickerModel {
String digits(int value, int length) {
return '$value'.padLeft(length, "0");
}

CustomPicker({DateTime currentTime, LocaleType locale})
: super(locale: locale) {
this.currentTime = currentTime ?? DateTime.now();
this.setLeftIndex(this.currentTime.hour);
this.setMiddleIndex(this.currentTime.minute);
this.setRightIndex(this.currentTime.second);
}
@override
String leftStringAtIndex(int index) {
if (index >= 0 && index < 24) {
return this.digits(index, 2);
} else {
return null;
}
}

@override
String middleStringAtIndex(int index) {
if (index >= 0 && index < 60) {
return this.digits(index, 2);
} else {
return null;
}
}

@override
String rightStringAtIndex(int index) {
if (index >= 0 && index < 60) {
return this.digits(index, 2);
} else {
return null;
}
}

@override
String leftDivider() {
return "|";
}

@override
String rightDivider() {
return "|";
}

@override
List<int> layoutProportions() {
return [1, 2, 1];
}

@override
DateTime finalTime() {
return currentTime.isUtc
? DateTime.utc(
currentTime.year,
currentTime.month,
currentTime.day,
this.currentLeftIndex(),
this.currentMiddleIndex(),
this.currentRightIndex())
: DateTime(
currentTime.year,
currentTime.month,
currentTime.day,
this.currentLeftIndex(),
this.currentMiddleIndex(),
this.currentRightIndex());
}
}
8 changes: 7 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import 'package:device_preview/device_preview.dart';
import 'package:flutter/material.dart';
import 'package:video_archive/video_archive_page.dart';
import 'package:intl/date_symbol_data_local.dart';

void main() {
initializeDateFormatting().then(
(_) => runApp(
MyApp(),
DevicePreview(
enabled: false,
builder: (context) => MyApp(),
),
),
);
}
Expand All @@ -14,6 +18,8 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
locale: DevicePreview.of(context).locale,
builder: DevicePreview.appBuilder,
home: VideoArchivePage(),
);
}
Expand Down
Loading

0 comments on commit 9ba2601

Please sign in to comment.