Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ Added show time on live timeline #217

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Expose two properties of LiveTimeIndicatorSettings
  • Loading branch information
DevyankShaw committed Apr 23, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 9a0dd938a77a7ada1731c94438a1183007b1394e
3 changes: 3 additions & 0 deletions lib/src/components/_internal_components.dart
Original file line number Diff line number Diff line change
@@ -99,6 +99,9 @@ class _LiveTimeIndicatorState extends State<LiveTimeIndicator> {
showTime: widget.liveTimeIndicatorSettings.showTime,
showTimeBackgroundView:
widget.liveTimeIndicatorSettings.showTimeBackgroundView,
bulletRadius: widget.liveTimeIndicatorSettings.bulletRadius,
timeBackgroundViewWidth:
widget.liveTimeIndicatorSettings.timeBackgroundViewWidth,
),
);
}
11 changes: 10 additions & 1 deletion lib/src/modals.dart
Original file line number Diff line number Diff line change
@@ -48,6 +48,12 @@ class LiveTimeIndicatorSettings {
/// Flag to show time backgroud view.
final bool showTimeBackgroundView;

/// Radius of bullet.
final double bulletRadius;

/// Width of time backgroud view.
final double timeBackgroundViewWidth;

/// Settings for live time line
const LiveTimeIndicatorSettings({
this.height = 1.0,
@@ -57,11 +63,14 @@ class LiveTimeIndicatorSettings {
this.showBullet = true,
this.showTime = false,
this.showTimeBackgroundView = false,
this.bulletRadius = 5.0,
this.timeBackgroundViewWidth = 60.0,
}) : assert(height >= 0, "Height must be greater than or equal to 0.");

factory LiveTimeIndicatorSettings.none() => LiveTimeIndicatorSettings(
color: Colors.transparent,
height: 0.0,
offset: 0.0,
showBullet: false,
);
}
18 changes: 14 additions & 4 deletions lib/src/painters.dart
Original file line number Diff line number Diff line change
@@ -91,16 +91,20 @@ class CurrentTimeLinePainter extends CustomPainter {
/// Flag to show time backgroud view.
final bool showTimeBackgroundView;

/// Width of time backgroud view.
final double timeBackgroundViewWidth;

/// Paints a single horizontal line at [offset].
CurrentTimeLinePainter({
this.showBullet = true,
required this.showBullet,
required this.color,
required this.height,
required this.offset,
this.bulletRadius = 5,
required this.bulletRadius,
required this.timeString,
required this.showTime,
required this.showTimeBackgroundView,
required this.timeBackgroundViewWidth,
});

@override
@@ -123,7 +127,7 @@ class CurrentTimeLinePainter extends CustomPainter {
Rect.fromLTWH(
max(3, offset.dx - 68),
offset.dy - 11,
60,
timeBackgroundViewWidth,
24,
),
Radius.circular(12),
@@ -154,5 +158,11 @@ class CurrentTimeLinePainter extends CustomPainter {
oldDelegate is CurrentTimeLinePainter &&
(color != oldDelegate.color ||
height != oldDelegate.height ||
offset != oldDelegate.offset);
offset != oldDelegate.offset ||
bulletRadius != oldDelegate.bulletRadius ||
timeString != oldDelegate.timeString ||
timeBackgroundViewWidth != oldDelegate.timeBackgroundViewWidth ||
showBullet != oldDelegate.showBullet ||
showTime != oldDelegate.showTime ||
showTimeBackgroundView != oldDelegate.showTimeBackgroundView);
}