-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Isfun
committed
Aug 9, 2020
1 parent
27f81a0
commit 9ba2601
Showing
6 changed files
with
406 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.