Skip to content

Commit e20fca6

Browse files
committed
added custom text to all types of gftoggle
1 parent 2ab8368 commit e20fca6

2 files changed

Lines changed: 79 additions & 23 deletions

File tree

example/lib/main.dart

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,83 @@ class _MyHomePageState extends State<MyHomePage> {
113113

114114
),
115115

116-
GFToggle(onChanged: (val){
117-
print(val);
118-
}, value: null, type: GFToggleType.square,
119-
duration: Duration(milliseconds: 400),
120-
),
116+
Container(
117+
margin: EdgeInsets.only(left: 10, right: 10, top:10, bottom: 10),
118+
child: Row(
119+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
120+
children: <Widget>[
121+
122+
123+
GFToggle(onChanged: null, value: null, type: GFToggleType.android,
124+
duration: Duration(milliseconds: 400),
125+
enabledText: 'hi',
126+
disabledText: 'k',
127+
128+
),
129+
GFToggle(onChanged: null, value: null, type: GFToggleType.ios,
130+
duration: Duration(milliseconds: 400),
131+
enabledText: 'hi',
132+
disabledText: 'k',
133+
134+
),
135+
136+
GFToggle(onChanged: null, value: null, type: GFToggleType.custom,
137+
duration: Duration(milliseconds: 400),
138+
enabledText: 'omm',
139+
disabledText: 'k',
140+
),
141+
GFToggle(onChanged: (val){
142+
print(val);
143+
}, value: null, type: GFToggleType.square,
144+
duration: Duration(milliseconds: 400),
145+
enabledText: 'li',
146+
disabledText: 'k',
147+
148+
),
149+
150+
151+
],
152+
),
153+
),
154+
155+
Container(
156+
margin: EdgeInsets.only(left: 10, right: 10, top:10, bottom: 10),
157+
child: Row(
158+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
159+
children: <Widget>[
160+
161+
162+
GFToggle(onChanged: null, value: null, type: GFToggleType.android,
163+
duration: Duration(milliseconds: 400),
164+
borderRadius: BorderRadius.all(Radius.circular(0)),
165+
boxShape: BoxShape.rectangle,
166+
121167

122-
GFToggle(onChanged: null, value: null, type: GFToggleType.android,
123-
duration: Duration(milliseconds: 400),
124-
),
125-
GFToggle(onChanged: null, value: null, type: GFToggleType.android,
126-
duration: Duration(milliseconds: 400),
127-
),
128-
GFToggle(onChanged: null, value: null, type: GFToggleType.custom,
129-
duration: Duration(milliseconds: 400),
130-
),
131168

132-
GFToggle(onChanged: null, value: null, type: GFToggleType.ios,
133-
duration: Duration(milliseconds: 400),
169+
),
170+
GFToggle(onChanged: null, value: null, type: GFToggleType.ios,
171+
duration: Duration(milliseconds: 400),
172+
borderRadius: BorderRadius.all(Radius.circular(0)),
173+
boxShape: BoxShape.rectangle,
134174

175+
176+
177+
),
178+
179+
GFToggle(onChanged: null, value: null, type: GFToggleType.custom,
180+
duration: Duration(milliseconds: 400),
181+
borderRadius: BorderRadius.all(Radius.circular(0)),
182+
boxShape: BoxShape.rectangle,
183+
184+
),
185+
186+
],
187+
),
135188
),
136189

190+
191+
192+
137193
Card(
138194

139195
child: Column(

lib/components/toggle/gf_toggle.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,24 @@ class _GFToggleState extends State<GFToggle> with TickerProviderStateMixin {
127127
: widget.borderRadius ??
128128
BorderRadius.all(Radius.circular(20))),
129129
child: Padding(
130-
padding: EdgeInsets.only(left: 3, right: 3, top: 3.4),
130+
padding: widget.type == GFToggleType.ios ? EdgeInsets.only(left: 3.5, right: 3.5, top: 5.4): EdgeInsets.only(left: 3, right: 3, top: 3.4),
131131
child: isOn
132132
? Text(
133133
widget.enabledText ??
134-
widget.type == GFToggleType.custom
134+
( widget.type == GFToggleType.custom
135135
? 'ON'
136-
: '',
136+
: ''),
137137
style: widget.enabledTextColor ??
138-
TextStyle(color: Colors.white, fontSize: 8),
138+
( widget.type == GFToggleType.ios ?TextStyle(color: Colors.white, fontSize: 12): TextStyle(color: Colors.white, fontSize: 8))
139139
)
140140
: Text(
141141
widget.disabledText ??
142-
widget.type == GFToggleType.custom
142+
( widget.type == GFToggleType.custom
143143
? 'OFF'
144-
: '',
144+
: ''),
145145
textAlign: TextAlign.end,
146146
style: widget.disabledTextColor ??
147-
TextStyle(color: Colors.white, fontSize: 8),
147+
( widget.type == GFToggleType.ios ?TextStyle(color: Colors.white, fontSize: 12): TextStyle(color: Colors.white, fontSize: 8))
148148
))),
149149
),
150150
Positioned(

0 commit comments

Comments
 (0)