Skip to content

Commit

Permalink
Fixed dart analysis issue with naming of 'countdown' constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
efortuna committed Oct 19, 2018
1 parent 5f0881a commit 8442b60
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.0.7] - 2018-10-19

* Fix small analysis error.

## [0.0.6] - 2018-10-19

* add countdown clock
Expand Down
56 changes: 30 additions & 26 deletions lib/flip_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ class FlipClock extends StatelessWidget {
final FlipDirection flipDirection;

/// Set countdown to true to have a countdown timer.
final bool countdown;
final bool countdownMode;
final bool _showHours;

/// Called when the countdown clock hits zero.
VoidCallback onDone;
final VoidCallback onDone;

FlipClock({
Key key,
@required DigitBuilder digitBuilder,
@required Widget separator,
@required this.startTime,
this.countdown = false,
this.countdownMode = false,
this.spacing = const EdgeInsets.symmetric(horizontal: 2.0),
this.flipDirection = FlipDirection.up,
}) : _showHours = true,
_digitBuilder = digitBuilder,
_separator = separator;
_separator = separator,
onDone = null;

FlipClock.simple({
Key key,
Expand All @@ -42,8 +43,9 @@ class FlipClock extends StatelessWidget {
BorderRadius borderRadius = const BorderRadius.all(Radius.circular(0.0)),
this.spacing = const EdgeInsets.symmetric(horizontal: 2.0),
this.flipDirection = FlipDirection.up,
}) : countdown = false,
_showHours = true {
}) : countdownMode = false,
_showHours = true,
onDone = null {
_digitBuilder = (context, digit) => Container(
alignment: Alignment.center,
width: 44.0,
Expand Down Expand Up @@ -88,7 +90,7 @@ class FlipClock extends StatelessWidget {
this.spacing = const EdgeInsets.symmetric(horizontal: 2.0),
this.onDone,
this.flipDirection = FlipDirection.up,
}) : countdown = true,
}) : countdownMode = true,
startTime = DateTime(2018, 1, 0, 0, 0, duration.inSeconds),
_showHours = duration.inHours > 0 {
_digitBuilder = (context, digit) => Container(
Expand Down Expand Up @@ -132,42 +134,44 @@ class FlipClock extends StatelessWidget {
final timeStream =
Stream<DateTime>.periodic(Duration(milliseconds: 1000), (_) {
var oldTime = time;
time = time.add(Duration(seconds: countdown ? -1 : 1));
time = time.add(Duration(seconds: countdownMode ? -1 : 1));
if (oldTime.day != time.day) {
time = oldTime;
if (onDone != null) onDone();
}
}
return time;
}).asBroadcastStream();

var digitList = <Widget>[];
// TODO(efortuna): Instead, allow the user to specify the format of time instead.
// Add hours if appropriate.
if (_showHours) {
digitList.addAll([_buildSegment(timeStream, (DateTime time) => time.hour ~/ 10,
digitList.addAll([
_buildSegment(timeStream, (DateTime time) => time.hour ~/ 10,
(DateTime time) => time.hour % 10, startTime),

Padding(
padding: spacing,
child: _separator,
)]);
)
]);
}
return Row(
mainAxisSize: MainAxisSize.min,
children: digitList..addAll([
// Minutes
_buildSegment(timeStream, (DateTime time) => time.minute ~/ 10,
(DateTime time) => time.minute % 10, startTime),

Padding(
padding: spacing,
child: _separator,
),
children: digitList
..addAll([
// Minutes
_buildSegment(timeStream, (DateTime time) => time.minute ~/ 10,
(DateTime time) => time.minute % 10, startTime),

Padding(
padding: spacing,
child: _separator,
),

// Seconds
_buildSegment(timeStream, (DateTime time) => time.second ~/ 10,
(DateTime time) => time.second % 10, startTime)
]),
// Seconds
_buildSegment(timeStream, (DateTime time) => time.second ~/ 10,
(DateTime time) => time.second % 10, startTime)
]),
);
}

Expand Down Expand Up @@ -200,7 +204,7 @@ class FlipClock extends StatelessWidget {

/// Signature for a function that creates a widget for a given index, e.g., in a
/// list.
typedef Widget IndexedItemBuilder(BuildContext, int);
typedef Widget IndexedItemBuilder(BuildContext, int );

/// Signature for a function that creates a widget for a value emitted from a [Stream]
typedef Widget StreamItemBuilder<T>(BuildContext, T);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flip_panel
description: A package for flip panel with built-in animation
version: 0.0.6
version: 0.0.7
author: hunghd <[email protected]>
homepage: https://github.com/hnvn/flutter_flip_panel

Expand Down

0 comments on commit 8442b60

Please sign in to comment.