-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [MDS-629] Add pin for linear progress (#240)
- Loading branch information
Showing
13 changed files
with
567 additions
and
13 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
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
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
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
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,72 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:moon_design/src/utils/color_premul_lerp.dart'; | ||
|
||
@immutable | ||
class MoonProgressPinColors extends ThemeExtension<MoonProgressPinColors> with DiagnosticableTreeMixin { | ||
/// Progress pin color. | ||
final Color pinColor; | ||
|
||
/// Progress pin border color. | ||
final Color pinBorderColor; | ||
|
||
/// Progress pin thumb color. | ||
final Color thumbColor; | ||
|
||
/// Progress pin shadow color. | ||
final Color shadowColor; | ||
|
||
/// Progress pin text color. | ||
final Color textColor; | ||
|
||
const MoonProgressPinColors({ | ||
required this.pinColor, | ||
required this.pinBorderColor, | ||
required this.thumbColor, | ||
required this.shadowColor, | ||
required this.textColor, | ||
}); | ||
|
||
@override | ||
MoonProgressPinColors copyWith({ | ||
Color? pinColor, | ||
Color? pinBorderColor, | ||
Color? thumbColor, | ||
Color? shadowColor, | ||
Color? textColor, | ||
}) { | ||
return MoonProgressPinColors( | ||
pinColor: pinColor ?? this.pinColor, | ||
pinBorderColor: pinBorderColor ?? this.pinBorderColor, | ||
thumbColor: thumbColor ?? this.thumbColor, | ||
shadowColor: shadowColor ?? this.shadowColor, | ||
textColor: textColor ?? this.textColor, | ||
); | ||
} | ||
|
||
@override | ||
MoonProgressPinColors lerp(ThemeExtension<MoonProgressPinColors>? other, double t) { | ||
if (other is! MoonProgressPinColors) return this; | ||
|
||
return MoonProgressPinColors( | ||
pinColor: colorPremulLerp(pinColor, other.pinColor, t)!, | ||
pinBorderColor: colorPremulLerp(pinBorderColor, other.pinBorderColor, t)!, | ||
thumbColor: colorPremulLerp(thumbColor, other.thumbColor, t)!, | ||
shadowColor: colorPremulLerp(shadowColor, other.shadowColor, t)!, | ||
textColor: colorPremulLerp(textColor, other.textColor, t)!, | ||
); | ||
} | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
super.debugFillProperties(properties); | ||
properties | ||
..add(DiagnosticsProperty("type", "MoonProgressPinColors")) | ||
..add(ColorProperty("pinColor", pinColor)) | ||
..add(ColorProperty("pinBorderColor", pinBorderColor)) | ||
..add(ColorProperty("thumbColor", thumbColor)) | ||
..add(ColorProperty("shadowColor", shadowColor)) | ||
..add(ColorProperty("textColor", textColor)); | ||
} | ||
} |
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,80 @@ | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
@immutable | ||
class MoonProgressPinProperties extends ThemeExtension<MoonProgressPinProperties> with DiagnosticableTreeMixin { | ||
/// Progress pin shadow elevation. | ||
final double shadowElevation; | ||
|
||
/// Vertical space between pin and linear progress. | ||
final double pinDistance; | ||
|
||
/// Progress pin width. | ||
final double pinWidth; | ||
|
||
/// Progress pin border width. | ||
final double pinBorderWidth; | ||
|
||
/// Thumb width multiplier for linear progress. | ||
final double thumbWidthMultiplier; | ||
|
||
/// Progress pin text style. | ||
final TextStyle textStyle; | ||
|
||
const MoonProgressPinProperties({ | ||
required this.shadowElevation, | ||
required this.pinDistance, | ||
required this.pinWidth, | ||
required this.pinBorderWidth, | ||
required this.thumbWidthMultiplier, | ||
required this.textStyle, | ||
}); | ||
|
||
@override | ||
MoonProgressPinProperties copyWith({ | ||
double? shadowElevation, | ||
double? pinDistance, | ||
double? pinWidth, | ||
double? pinBorderWidth, | ||
double? thumbWidthMultiplier, | ||
TextStyle? textStyle, | ||
}) { | ||
return MoonProgressPinProperties( | ||
shadowElevation: shadowElevation ?? this.shadowElevation, | ||
pinDistance: pinDistance ?? this.pinDistance, | ||
pinWidth: pinWidth ?? this.pinWidth, | ||
pinBorderWidth: pinBorderWidth ?? this.pinBorderWidth, | ||
thumbWidthMultiplier: thumbWidthMultiplier ?? this.thumbWidthMultiplier, | ||
textStyle: textStyle ?? this.textStyle, | ||
); | ||
} | ||
|
||
@override | ||
MoonProgressPinProperties lerp(ThemeExtension<MoonProgressPinProperties>? other, double t) { | ||
if (other is! MoonProgressPinProperties) return this; | ||
|
||
return MoonProgressPinProperties( | ||
shadowElevation: lerpDouble(shadowElevation, other.shadowElevation, t)!, | ||
pinDistance: lerpDouble(pinDistance, other.pinDistance, t)!, | ||
pinWidth: lerpDouble(pinWidth, other.pinWidth, t)!, | ||
pinBorderWidth: lerpDouble(pinBorderWidth, other.pinBorderWidth, t)!, | ||
thumbWidthMultiplier: lerpDouble(thumbWidthMultiplier, other.thumbWidthMultiplier, t)!, | ||
textStyle: TextStyle.lerp(textStyle, other.textStyle, t)!, | ||
); | ||
} | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
super.debugFillProperties(properties); | ||
properties | ||
..add(DiagnosticsProperty("type", "MoonProgressPinProperties")) | ||
..add(DoubleProperty("shadowElevation", shadowElevation)) | ||
..add(DoubleProperty("pinDistance", pinDistance)) | ||
..add(DoubleProperty("pinWidth", pinWidth)) | ||
..add(DoubleProperty("pinBorderWidth", pinBorderWidth)) | ||
..add(DoubleProperty("thumbWidthMultiplier", thumbWidthMultiplier)) | ||
..add(DiagnosticsProperty<TextStyle>("textStyle", textStyle)); | ||
} | ||
} |
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,74 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:moon_design/src/theme/progress_pin/progress_pin_colors.dart'; | ||
import 'package:moon_design/src/theme/progress_pin/progress_pin_properties.dart'; | ||
import 'package:moon_design/src/theme/tokens/tokens.dart'; | ||
|
||
@immutable | ||
class MoonProgressPinTheme extends ThemeExtension<MoonProgressPinTheme> with DiagnosticableTreeMixin { | ||
/// MDS tokens. | ||
final MoonTokens tokens; | ||
|
||
/// Progress pin colors. | ||
final MoonProgressPinColors colors; | ||
|
||
/// Progress pin properties. | ||
final MoonProgressPinProperties properties; | ||
|
||
MoonProgressPinTheme({ | ||
required this.tokens, | ||
MoonProgressPinColors? colors, | ||
MoonProgressPinProperties? properties, | ||
}) : colors = colors ?? | ||
MoonProgressPinColors( | ||
pinColor: tokens.colors.popo, | ||
pinBorderColor: tokens.colors.goten, | ||
thumbColor: tokens.colors.goten, | ||
shadowColor: tokens.colors.popo, | ||
textColor: tokens.colors.goten, | ||
), | ||
properties = properties ?? | ||
MoonProgressPinProperties( | ||
pinDistance: 6, | ||
pinWidth: 36, | ||
pinBorderWidth: 2, | ||
thumbWidthMultiplier: 1.5, | ||
shadowElevation: 6, | ||
textStyle: tokens.typography.caption.text10.copyWith(letterSpacing: 0.5), | ||
); | ||
|
||
@override | ||
MoonProgressPinTheme copyWith({ | ||
MoonTokens? tokens, | ||
MoonProgressPinColors? colors, | ||
MoonProgressPinProperties? properties, | ||
}) { | ||
return MoonProgressPinTheme( | ||
tokens: tokens ?? this.tokens, | ||
colors: colors ?? this.colors, | ||
properties: properties ?? this.properties, | ||
); | ||
} | ||
|
||
@override | ||
MoonProgressPinTheme lerp(ThemeExtension<MoonProgressPinTheme>? other, double t) { | ||
if (other is! MoonProgressPinTheme) return this; | ||
|
||
return MoonProgressPinTheme( | ||
tokens: tokens.lerp(other.tokens, t), | ||
colors: colors.lerp(other.colors, t), | ||
properties: properties.lerp(other.properties, t), | ||
); | ||
} | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder diagnosticProperties) { | ||
super.debugFillProperties(diagnosticProperties); | ||
diagnosticProperties | ||
..add(DiagnosticsProperty("type", "MoonProgressPinTheme")) | ||
..add(DiagnosticsProperty<MoonTokens>("tokens", tokens)) | ||
..add(DiagnosticsProperty<MoonProgressPinColors>("colors", colors)) | ||
..add(DiagnosticsProperty<MoonProgressPinProperties>("properties", properties)); | ||
} | ||
} |
Oops, something went wrong.