-
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.
fixed widget book, created input icon button
- Loading branch information
1 parent
38b2e2a
commit ee1c468
Showing
8 changed files
with
170 additions
and
206 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)); | ||
} | ||
} |
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
Oops, something went wrong.