Line data Source code
1 : import 'package:flutter/material.dart';
2 : import 'package:flutter/services.dart';
3 :
4 : class HelperTileWidget extends StatelessWidget {
5 : final String name;
6 : final String trigger;
7 : final String versionMin;
8 : final String versionMax;
9 : final bool isDisabled;
10 : final Function onTapCallback;
11 : final String type;
12 :
13 1 : const HelperTileWidget({
14 : Key key,
15 : @required this.name,
16 : this.type,
17 : this.trigger,
18 : this.versionMax,
19 : this.versionMin,
20 : this.isDisabled,
21 : this.onTapCallback,
22 1 : }) : super(key: key);
23 :
24 1 : @override
25 : Widget build(BuildContext context) {
26 : const borderRadius = 8.0;
27 :
28 1 : return Container(
29 : height: 56.0,
30 1 : decoration: BoxDecoration(
31 1 : borderRadius: BorderRadius.circular(borderRadius),
32 : color: Colors.white,
33 1 : boxShadow: [
34 1 : BoxShadow(
35 2 : color: Color(0xFF2C77B6).withOpacity(0.2),
36 : spreadRadius: 1,
37 : blurRadius: 12,
38 1 : offset: Offset(0, 3),
39 : ),
40 : ],
41 : ),
42 1 : key: ValueKey('helperTileWidget'),
43 1 : child: ClipRRect(
44 1 : borderRadius: BorderRadius.circular(borderRadius),
45 1 : child: Material(
46 : color: Colors.transparent,
47 1 : child: InkWell(
48 1 : onTap: () {
49 1 : HapticFeedback.selectionClick();
50 :
51 1 : if (onTapCallback != null) {
52 2 : onTapCallback();
53 : }
54 : },
55 1 : child: Row(
56 : mainAxisAlignment: MainAxisAlignment.spaceBetween,
57 1 : children: [
58 1 : Row(
59 1 : children: [
60 1 : _buildEnabledIndicator(),
61 1 : Padding(
62 : padding: const EdgeInsets.only(
63 : left: 12.0,
64 : ),
65 1 : child: _buildInfos(),
66 : ),
67 : ],
68 : ),
69 1 : Padding(
70 : padding: const EdgeInsets.only(right: 8.0),
71 1 : child: _buildVersions(context),
72 : ),
73 : ],
74 : ),
75 : ),
76 : ),
77 : ),
78 : );
79 : }
80 :
81 1 : Widget _buildEnabledIndicator() {
82 1 : return Container(
83 : width: 6.0,
84 1 : decoration: BoxDecoration(
85 2 : color: isDisabled ? Color(0xFFEB5160) : Color(0xFF3EB4D9),
86 : ),
87 : );
88 : }
89 :
90 1 : Widget _buildInfos() {
91 1 : return Column(
92 : crossAxisAlignment: CrossAxisAlignment.start,
93 : mainAxisAlignment: MainAxisAlignment.center,
94 1 : children: [
95 1 : Text(
96 1 : name,
97 : overflow: TextOverflow.ellipsis,
98 1 : style: TextStyle(
99 : fontSize: 16.0,
100 : ),
101 : ),
102 1 : SizedBox(
103 : height: 5.0,
104 : ),
105 1 : Row(
106 1 : children: [
107 1 : Text(
108 1 : type,
109 1 : style: TextStyle(
110 : fontSize: 10.0,
111 : fontWeight: FontWeight.w300,
112 : ),
113 : ),
114 1 : Text(
115 : '- ',
116 1 : style: TextStyle(
117 : fontSize: 10.0,
118 : fontWeight: FontWeight.w300,
119 : ),
120 : ),
121 1 : Text(
122 1 : trigger,
123 1 : style: TextStyle(
124 : fontSize: 10.0,
125 : fontWeight: FontWeight.w300,
126 : ),
127 : ),
128 : ],
129 : ),
130 : ],
131 : );
132 : }
133 :
134 1 : Widget _buildVersions(
135 : BuildContext context,
136 : ) {
137 1 : return Column(
138 : mainAxisAlignment: MainAxisAlignment.center,
139 : crossAxisAlignment: CrossAxisAlignment.end,
140 1 : children: [
141 1 : Text(
142 : 'Available versions',
143 1 : style: TextStyle(
144 : fontSize: 10.0,
145 2 : color: Theme.of(context).accentColor,
146 : fontWeight: FontWeight.bold,
147 : ),
148 : ),
149 1 : SizedBox(
150 : height: 5.0,
151 : ),
152 1 : Row(
153 1 : children: [
154 1 : Text(
155 2 : '${versionMin ?? 'first'} ',
156 1 : style: TextStyle(
157 : fontSize: 10.0,
158 : fontWeight: FontWeight.w300,
159 : ),
160 : ),
161 1 : Icon(
162 : Icons.arrow_forward,
163 : size: 10.0,
164 : ),
165 1 : Text(
166 2 : ' ${versionMax ?? 'last'}',
167 1 : style: TextStyle(
168 : fontSize: 10.0,
169 : fontWeight: FontWeight.w300,
170 : ),
171 : ),
172 : ],
173 : ),
174 : ],
175 : );
176 : }
177 : }
|