-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Select input now wraps a ZetaTextInput feat: Dropdown now has a builder function to allow building custom children fix: Select input menu appears in the correct position below the input
- Loading branch information
1 parent
4b5c568
commit 6ac8c4d
Showing
9 changed files
with
438 additions
and
887 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../../../zeta_flutter.dart'; | ||
|
||
/// An icon button to be used internally in inputs | ||
class InputIconButton extends StatelessWidget { | ||
/// Creates a new [InputIconButton] | ||
const InputIconButton({ | ||
super.key, | ||
required this.icon, | ||
required this.onTap, | ||
required this.disabled, | ||
required this.size, | ||
required this.color, | ||
}); | ||
|
||
/// The icon | ||
final IconData icon; | ||
|
||
/// On tap | ||
final VoidCallback onTap; | ||
|
||
/// Disables the icon and its on tap | ||
final bool disabled; | ||
|
||
/// The size of the icon | ||
final ZetaWidgetSize size; | ||
|
||
/// The color of the icon | ||
final Color color; | ||
|
||
double get _iconSize { | ||
switch (size) { | ||
case ZetaWidgetSize.large: | ||
return ZetaSpacing.xL2; | ||
case ZetaWidgetSize.medium: | ||
return ZetaSpacing.xL; | ||
case ZetaWidgetSize.small: | ||
return ZetaSpacing.large; | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final colors = Zeta.of(context).colors; | ||
|
||
return IconButton( | ||
padding: EdgeInsets.all(_iconSize / 2), | ||
constraints: BoxConstraints( | ||
maxHeight: _iconSize * 2, | ||
maxWidth: _iconSize * 2, | ||
minHeight: _iconSize * 2, | ||
minWidth: _iconSize * 2, | ||
), | ||
color: !disabled ? color : colors.iconDisabled, | ||
onPressed: disabled ? null : onTap, | ||
iconSize: _iconSize, | ||
icon: Icon(icon), | ||
); | ||
} | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
super.debugFillProperties(properties); | ||
properties | ||
..add(DiagnosticsProperty<IconData>('icon', icon)) | ||
..add(ObjectFlagProperty<VoidCallback>.has('onTap', onTap)) | ||
..add(DiagnosticsProperty<bool>('disabled', disabled)) | ||
..add(ColorProperty('color', color)) | ||
..add(EnumProperty<ZetaWidgetSize>('size', size)); | ||
} | ||
} |
Oops, something went wrong.