-
Notifications
You must be signed in to change notification settings - Fork 37
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
Showing
5 changed files
with
117 additions
and
10 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,31 +1,39 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_svg/flutter_svg.dart'; | ||
import 'package:optimus/src/pictogram/pictograms.dart'; | ||
import 'package:optimus/src/theme/theme.dart'; | ||
import 'package:optimus/src/widget_size.dart'; | ||
import 'package:optimus/optimus.dart'; | ||
|
||
enum OptimusPictogramSize { small, medium, large } | ||
|
||
/// Pictograms are a valuable tool for conveying information efficiently, | ||
/// promoting interactivity, and simplifying complex concepts. | ||
class OptimusPictogram extends StatelessWidget { | ||
const OptimusPictogram({ | ||
super.key, | ||
required this.variant, | ||
this.size = OptimusWidgetSize.large, | ||
this.size = OptimusPictogramSize.large, | ||
}); | ||
|
||
/// The variant of the pictogram. | ||
final OptimusPictogramVariant variant; | ||
|
||
/// The size of the pictogram. Defaults to [OptimusWidgetSize.large] | ||
final OptimusWidgetSize size; | ||
/// The size of the pictogram. Defaults to [OptimusPictogramSize.large] | ||
final OptimusPictogramSize size; | ||
|
||
@override | ||
Widget build(BuildContext context) => SizedBox( | ||
width: size.getValue(context.tokens), | ||
height: size.getValue(context.tokens), | ||
width: size.getSize(context.tokens), | ||
height: size.getSize(context.tokens), | ||
child: SvgPicture.asset( | ||
variant.path(context.theme.brightness), | ||
package: 'optimus', | ||
), | ||
); | ||
} | ||
|
||
extension on OptimusPictogramSize { | ||
double getSize(OptimusTokens tokens) => switch (this) { | ||
OptimusPictogramSize.small => tokens.sizing600, | ||
OptimusPictogramSize.medium => tokens.sizing800, | ||
OptimusPictogramSize.large => 80, // TODO(witwash): add token | ||
}; | ||
} |
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 |
---|---|---|
|
@@ -26,6 +26,7 @@ enum OptimusPictogramVariant { | |
settings, | ||
success, | ||
system_error, | ||
tada, | ||
target, | ||
upload; | ||
|
||
|
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