-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp_elevated_button.dart
102 lines (97 loc) · 3.37 KB
/
app_elevated_button.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:srlm_app/global/dimensions.dart';
import 'package:srlm_app/constants/app_colors.dart';
class AppElevatedButton extends StatelessWidget {
const AppElevatedButton({
Key? key,
required this.title,
required this.onPress,
this.leadingIcon = '',
this.trailingIcon = '',
required this.isNotDisabled,
this.width = double.infinity,
this.borderColor = false,
}) : super(key: key);
final String title;
final VoidCallback onPress;
final String leadingIcon;
final String trailingIcon;
final bool isNotDisabled;
final double? width;
final bool borderColor;
@override
Widget build(BuildContext context) {
var icon = '';
if (trailingIcon.isNotEmpty) {
icon = trailingIcon;
} else if (leadingIcon.isNotEmpty) {
icon = leadingIcon;
}
return SizedBox(
width: width,
height: scaleH(context, 39),
child: Directionality(
textDirection:
trailingIcon.isNotEmpty ? TextDirection.rtl : TextDirection.ltr,
child: ClipRRect(
borderRadius: BorderRadius.circular(scaleW(context, 10)),
child: ElevatedButton.icon(
onPressed: !isNotDisabled ? null : onPress,
style: ButtonStyle(
backgroundColor: borderColor
? MaterialStateProperty.all(AppColors.neutralsWhite)
: isNotDisabled
? MaterialStateProperty.all(AppColors.primary_500)
: MaterialStateProperty.all(AppColors.disabledColor),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(
color: isNotDisabled
? AppColors.primary_500
: AppColors.disabledColor,
),
),
),
),
label: Text(
title,
style: Get.theme.textTheme.titleMedium?.copyWith(
color: borderColor
? AppColors.primary_500
: isNotDisabled
? AppColors.neutralsWhite
: AppColors.neutrals_500,
fontSize: scaleW(context, 14),
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.center,
),
icon: icon.isNotEmpty
? SvgPicture.asset(
icon,
fit: BoxFit.fitHeight,
colorFilter: borderColor
? ColorFilter.mode(
AppColors.buttonColor,
BlendMode.srcIn,
)
: isNotDisabled
? ColorFilter.mode(
AppColors.neutralsWhite,
BlendMode.srcIn,
)
: ColorFilter.mode(
AppColors.neutrals_500,
BlendMode.srcIn,
),
)
: const SizedBox(),
),
),
),
);
}
}