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: [MDS-1129] Deprecate Tag uppercase property #400

Merged
merged 3 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion example/assets/code_snippets/combobox_multi_select.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class _ComboboxMultiSelectState extends State<ComboboxMultiSelect> {
onTap: () => setState(() => _selectedOptions.clear()),
child: MoonTag(
tagSize: MoonTagSize.xs,
isUpperCase: false,
backgroundColor: context.moonColors!.bulma,
label: Text(
"${_selectedOptions.keys.length}",
Expand Down
1 change: 0 additions & 1 deletion example/assets/code_snippets/dropdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class _DropdownState extends State<Dropdown> {
? Center(
child: MoonTag(
tagSize: MoonTagSize.xs,
isUpperCase: false,
backgroundColor: context.moonColors!.bulma,
onTap: () => setState(() => _availableChoices.updateAll((key, value) => false)),
label: Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ class _ComboboxMultiSelectStoryState extends State<ComboboxMultiSelectStory> {
? Center(
child: MoonTag(
tagSize: MoonTagSize.xs,
isUpperCase: false,
backgroundColor: context.moonColors!.bulma,
onTap: () => setState(() => _selectedOptions.clear()),
label: Text(
Expand Down
1 change: 0 additions & 1 deletion example/lib/src/storybook/stories/primitives/dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ class _DropdownStoryState extends State<DropdownStory> {
? Center(
child: MoonTag(
tagSize: MoonTagSize.xs,
isUpperCase: false,
backgroundColor: context.moonColors!.bulma,
onTap: () => setState(() => _availableChoices.updateAll((key, value) => false)),
label: Text(
Expand Down
8 changes: 1 addition & 7 deletions example/lib/src/storybook/stories/primitives/tag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,13 @@ class TagStory extends StatelessWidget {
initial: true,
);

final setUpperCaseKnob = context.knobs.boolean(
label: "isUpperCase",
description: "Use upper case text for MoonTag.",
);

return Center(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(vertical: 64.0, horizontal: 16.0),
child: MoonTag(
borderRadius: borderRadiusKnob != null ? BorderRadius.circular(borderRadiusKnob.toDouble()) : null,
onTap: () {},
tagSize: tagSizeKnob,
isUpperCase: setUpperCaseKnob,
backgroundColor: backgroundColor,
leading: showLeadingKnob
? Icon(
Expand All @@ -107,7 +101,7 @@ class TagStory extends StatelessWidget {
: null,
label: showLabelKnob
? Text(
setUpperCaseKnob ? customLabelTextKnob.toUpperCase() : customLabelTextKnob,
customLabelTextKnob,
style: TextStyle(color: textColor),
)
: null,
Expand Down
2 changes: 2 additions & 0 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import Foundation

import package_info_plus
import path_provider_foundation
import shared_preferences_foundation

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
}
9 changes: 9 additions & 0 deletions lib/src/theme/tag/tag_size_properties.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class MoonTagSizeProperties extends ThemeExtension<MoonTagSizeProperties> with D
final TextStyle textStyle;

/// The upper case text style of the MoonTag.
@Deprecated(
"Handle upper case text style properly at place of usage. This property will be removed in 1.0.0 release.",
)
final TextStyle upperCaseTextStyle;

const MoonTagSizeProperties({
Expand All @@ -33,6 +36,9 @@ class MoonTagSizeProperties extends ThemeExtension<MoonTagSizeProperties> with D
required this.iconSizeValue,
required this.padding,
required this.textStyle,
@Deprecated(
"Handle upper case text style properly at place of usage. This property will be removed in 1.0.0 release.",
)
required this.upperCaseTextStyle,
});

Expand All @@ -53,6 +59,7 @@ class MoonTagSizeProperties extends ThemeExtension<MoonTagSizeProperties> with D
iconSizeValue: iconSizeValue ?? this.iconSizeValue,
padding: padding ?? this.padding,
textStyle: textStyle ?? this.textStyle,
// ignore: deprecated_member_use_from_same_package
upperCaseTextStyle: upperCaseTextStyle ?? this.upperCaseTextStyle,
);
}
Expand All @@ -68,6 +75,7 @@ class MoonTagSizeProperties extends ThemeExtension<MoonTagSizeProperties> with D
iconSizeValue: lerpDouble(iconSizeValue, other.iconSizeValue, t)!,
padding: EdgeInsetsGeometry.lerp(padding, other.padding, t)!,
textStyle: TextStyle.lerp(textStyle, other.textStyle, t)!,
// ignore: deprecated_member_use_from_same_package
upperCaseTextStyle: TextStyle.lerp(upperCaseTextStyle, other.upperCaseTextStyle, t)!,
);
}
Expand All @@ -83,6 +91,7 @@ class MoonTagSizeProperties extends ThemeExtension<MoonTagSizeProperties> with D
..add(DoubleProperty("iconSizeValue", iconSizeValue))
..add(DiagnosticsProperty<EdgeInsetsGeometry>("padding", padding))
..add(DiagnosticsProperty<TextStyle>("textStyle", textStyle))
// ignore: deprecated_member_use_from_same_package
..add(DiagnosticsProperty<TextStyle>("upperCaseTextStyle", upperCaseTextStyle));
}
}
10 changes: 9 additions & 1 deletion lib/src/widgets/tag/tag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ enum MoonTagSize {

class MoonTag extends StatelessWidget {
/// Whether to use the upper case text style for the tag.
@Deprecated(
"Handle upper case text style properly at place of usage. This property will be removed in 1.0.0 release.",
)
final bool isUpperCase;

/// The border radius of the tag.
Expand Down Expand Up @@ -64,7 +67,10 @@ class MoonTag extends StatelessWidget {
/// Creates a Moon Design tag.
const MoonTag({
super.key,
this.isUpperCase = true,
@Deprecated(
"Handle upper case text style properly at place of usage. This property will be removed in 1.0.0 release.",
)
this.isUpperCase = false,
this.borderRadius,
this.backgroundColor,
this.height,
Expand Down Expand Up @@ -147,7 +153,9 @@ class MoonTag extends StatelessWidget {
size: effectiveMoonTagSize.iconSizeValue,
),
child: DefaultTextStyle(
// ignore: deprecated_member_use_from_same_package
style: isUpperCase
// ignore: deprecated_member_use_from_same_package
? effectiveMoonTagSize.upperCaseTextStyle.copyWith(color: effectiveTextColor)
: effectiveMoonTagSize.textStyle.copyWith(color: effectiveTextColor),
child: Row(
Expand Down