Skip to content

Commit 35dd72a

Browse files
authored
Merge pull request #30 from webreinvent/feature/Task-7797-update-button-text-with-icon
Feature->Develop | Task 7797 update button text with icon
2 parents 46d3b25 + 79f8df3 commit 35dd72a

File tree

3 files changed

+41
-21
lines changed

3 files changed

+41
-21
lines changed

lib/vaahextendflutter/widgets/atoms/buttons.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class ButtonText extends StatelessWidget {
297297
class ButtonTextWithIcon extends StatelessWidget {
298298
final OnPressed onPressed;
299299
final String text;
300-
final IconData? iconData;
300+
final Widget leading;
301301
final ButtonStyle? style;
302302
final ButtonType? buttonType;
303303
final Color? foregroundColor;
@@ -310,7 +310,7 @@ class ButtonTextWithIcon extends StatelessWidget {
310310
Key? key,
311311
required this.onPressed,
312312
required this.text,
313-
required this.iconData,
313+
required this.leading,
314314
this.style,
315315
this.buttonType,
316316
this.foregroundColor,
@@ -341,10 +341,7 @@ class ButtonTextWithIcon extends StatelessWidget {
341341
fontSize: fontSize,
342342
),
343343
),
344-
icon: FaIcon(
345-
iconData,
346-
size: iconSize,
347-
),
344+
icon: leading,
348345
);
349346
}
350347
}

lib/vaahextendflutter/widgets/atoms/input_text.dart

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class InputText extends StatelessWidget {
2626
final Function()? suffixOnTap;
2727
final int? minLines;
2828
final int? maxLines;
29+
final InputBorderType inputBorder;
2930

3031
const InputText({
3132
super.key,
@@ -48,19 +49,20 @@ class InputText extends StatelessWidget {
4849
this.suffixOnTap,
4950
this.minLines,
5051
this.maxLines,
52+
this.inputBorder = InputBorderType.outline,
5153
});
5254

5355
@override
5456
Widget build(BuildContext context) {
5557
return TextFormField(
5658
decoration: InputDecoration(
5759
contentPadding: padding,
58-
border: border(AppTheme.colors['black']!.shade400),
59-
enabledBorder: border(AppTheme.colors['black']!.shade400),
60-
disabledBorder: border(AppTheme.colors['black']!.shade300),
61-
focusedBorder: border(AppTheme.colors['black']!.shade400),
62-
errorBorder: border(AppTheme.colors['danger']!.shade400),
63-
focusedErrorBorder: border(AppTheme.colors['danger']!.shade400),
60+
border: getInputBorder(inputBorder, AppTheme.colors['black']!.shade400),
61+
enabledBorder: getInputBorder(inputBorder, AppTheme.colors['black']!.shade400),
62+
disabledBorder: getInputBorder(inputBorder, AppTheme.colors['black']!.shade400),
63+
focusedBorder: getInputBorder(inputBorder, AppTheme.colors['black']!.shade400),
64+
errorBorder: getInputBorder(inputBorder, AppTheme.colors['black']!.shade400),
65+
focusedErrorBorder: getInputBorder(inputBorder, AppTheme.colors['black']!.shade400),
6466
errorStyle: TextStyle(color: AppTheme.colors['danger']!.shade400),
6567
hintText: label,
6668
hintStyle: TextStyle(
@@ -123,14 +125,29 @@ class InputText extends StatelessWidget {
123125
);
124126
}
125127

126-
OutlineInputBorder border(Color color) {
127-
return OutlineInputBorder(
128-
borderRadius: BorderRadius.circular(borderRadius),
129-
borderSide: BorderSide(
130-
width: 1,
131-
color: color,
132-
),
133-
);
128+
InputBorder getInputBorder(InputBorderType inputBorderType, Color color) {
129+
switch (inputBorderType) {
130+
case InputBorderType.none:
131+
return InputBorder.none;
132+
133+
case InputBorderType.underline:
134+
return UnderlineInputBorder(
135+
borderRadius: BorderRadius.circular(borderRadius),
136+
borderSide: BorderSide(
137+
width: 1,
138+
color: color,
139+
),
140+
);
141+
142+
case InputBorderType.outline:
143+
return OutlineInputBorder(
144+
borderRadius: BorderRadius.circular(borderRadius),
145+
borderSide: BorderSide(
146+
width: 1,
147+
color: color,
148+
),
149+
);
150+
}
134151
}
135152

136153
double getFontSize() {
@@ -148,3 +165,9 @@ class InputText extends StatelessWidget {
148165
}
149166
}
150167
}
168+
169+
enum InputBorderType {
170+
underline,
171+
outline,
172+
none,
173+
}

lib/views/pages/ui/components/buttons/icon_and_label.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ButtonIconLabelPreview extends StatelessWidget {
3434
ButtonTextWithIcon(
3535
onPressed: () {},
3636
text: "Icon Button",
37-
iconData: FontAwesomeIcons.user,
37+
leading: const Icon(FontAwesomeIcons.user),
3838
),
3939
],
4040
),

0 commit comments

Comments
 (0)