Skip to content

Commit 5fbcd9a

Browse files
committed
move f1 apikey setting to the championship screen
1 parent 8e8f9b3 commit 5fbcd9a

File tree

2 files changed

+131
-119
lines changed

2 files changed

+131
-119
lines changed

lib/Screens/Settings/championship.dart

Lines changed: 131 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,137 @@ class _ChampionshipScreenState extends State<ChampionshipScreen> {
8282
),
8383
championship == 'Formula 1'
8484
? ListTile(
85-
trailing: Radio(
86-
value: true,
87-
groupValue: useOfficialDataSoure,
88-
onChanged: (value) => onF1SourceChanged(value),
85+
trailing: Row(
86+
mainAxisSize: MainAxisSize.min,
87+
children: [
88+
Padding(
89+
padding: EdgeInsets.only(right: 5),
90+
child: IconButton(
91+
onPressed: () async {
92+
final TextEditingController controller =
93+
TextEditingController();
94+
showCustomBottomSheet(
95+
context,
96+
StatefulBuilder(
97+
builder: (context, setState) => Padding(
98+
padding: EdgeInsets.fromLTRB(
99+
20,
100+
15,
101+
20,
102+
15,
103+
),
104+
child: Column(
105+
mainAxisAlignment: MainAxisAlignment.center,
106+
crossAxisAlignment:
107+
CrossAxisAlignment.center,
108+
mainAxisSize: MainAxisSize.min,
109+
children: <Widget>[
110+
Text(
111+
AppLocalizations.of(context)!
112+
.updateApiKey,
113+
style: TextStyle(
114+
fontSize: 20.0,
115+
), // here
116+
textAlign: TextAlign.center,
117+
),
118+
Padding(
119+
padding: EdgeInsets.only(
120+
top: 15, bottom: 10),
121+
child: Text(
122+
AppLocalizations.of(context)!
123+
.updateApiKeySub,
124+
textAlign: TextAlign.justify,
125+
),
126+
),
127+
TextField(
128+
controller: controller,
129+
autofocus: true,
130+
decoration: InputDecoration(
131+
border: OutlineInputBorder(),
132+
hintText:
133+
AppLocalizations.of(context)!
134+
.apiKey,
135+
hintStyle: TextStyle(
136+
fontWeight: FontWeight.w100,
137+
),
138+
),
139+
),
140+
Padding(
141+
padding:
142+
EdgeInsets.only(top: 20, bottom: 7),
143+
child: Container(
144+
width: double.infinity,
145+
height: 50,
146+
child: FilledButton.tonal(
147+
onPressed: () {
148+
Hive.box('settings').put(
149+
'officialApiKey',
150+
controller.text,
151+
);
152+
Navigator.of(context).pop();
153+
setState(() {});
154+
},
155+
child: Text(
156+
AppLocalizations.of(context)!
157+
.save,
158+
),
159+
),
160+
),
161+
),
162+
Padding(
163+
padding:
164+
EdgeInsets.only(top: 7, bottom: 7),
165+
child: Container(
166+
width: double.infinity,
167+
height: 50,
168+
child: OutlinedButton(
169+
onPressed: () {
170+
Hive.box('settings').put(
171+
'officialApiKey',
172+
Constants().F1_API_KEY,
173+
);
174+
Navigator.of(context).pop();
175+
setState(() {});
176+
},
177+
child: Text(
178+
AppLocalizations.of(context)!
179+
.reset,
180+
),
181+
),
182+
),
183+
),
184+
Padding(
185+
padding:
186+
EdgeInsets.only(top: 7, bottom: 20),
187+
child: Container(
188+
width: double.infinity,
189+
height: 50,
190+
child: OutlinedButton(
191+
onPressed: () {
192+
Navigator.of(context).pop();
193+
},
194+
child: Text(
195+
AppLocalizations.of(context)!
196+
.close,
197+
),
198+
),
199+
),
200+
),
201+
],
202+
),
203+
),
204+
),
205+
);
206+
},
207+
icon: Icon(Icons.settings_outlined),
208+
),
209+
),
210+
Radio(
211+
value: true,
212+
groupValue: useOfficialDataSoure,
213+
onChanged: (value) => onF1SourceChanged(value),
214+
),
215+
],
89216
),
90217
title: Padding(
91218
padding: EdgeInsets.only(left: 80),

lib/Screens/Settings/other.dart

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import 'dart:math' as math;
2121

2222
import 'package:boxbox/api/services/formulae.dart';
23-
import 'package:boxbox/helpers/bottom_sheet.dart';
24-
import 'package:boxbox/helpers/constants.dart';
2523
import 'package:boxbox/l10n/app_localizations.dart';
2624
import 'package:flutter/material.dart';
2725
import 'package:fluttertoast/fluttertoast.dart';
@@ -108,119 +106,6 @@ class _OtherSettingsScreenState extends State<OtherSettingsScreen> {
108106
);
109107
},
110108
),
111-
if (championship == 'Formula 1')
112-
ListTile(
113-
title: Text(
114-
AppLocalizations.of(context)!.apiKey,
115-
),
116-
onTap: () {
117-
final TextEditingController controller =
118-
TextEditingController();
119-
showCustomBottomSheet(
120-
context,
121-
StatefulBuilder(
122-
builder: (context, setState) => Padding(
123-
padding: EdgeInsets.fromLTRB(
124-
20,
125-
15,
126-
20,
127-
15,
128-
),
129-
child: Column(
130-
mainAxisAlignment: MainAxisAlignment.center,
131-
crossAxisAlignment: CrossAxisAlignment.center,
132-
mainAxisSize: MainAxisSize.min,
133-
children: <Widget>[
134-
Text(
135-
AppLocalizations.of(context)!.updateApiKey,
136-
style: TextStyle(
137-
fontSize: 20.0,
138-
), // here
139-
textAlign: TextAlign.center,
140-
),
141-
Padding(
142-
padding: EdgeInsets.only(top: 15, bottom: 10),
143-
child: Text(
144-
AppLocalizations.of(context)!.updateApiKeySub,
145-
textAlign: TextAlign.justify,
146-
),
147-
),
148-
TextField(
149-
controller: controller,
150-
autofocus: true,
151-
decoration: InputDecoration(
152-
border: OutlineInputBorder(),
153-
hintText: AppLocalizations.of(context)!.apiKey,
154-
hintStyle: TextStyle(
155-
fontWeight: FontWeight.w100,
156-
),
157-
),
158-
),
159-
Padding(
160-
padding: EdgeInsets.only(top: 20, bottom: 7),
161-
child: Container(
162-
width: double.infinity,
163-
height: 50,
164-
child: FilledButton.tonal(
165-
onPressed: () {
166-
Hive.box('settings').put(
167-
'officialApiKey',
168-
controller.text,
169-
);
170-
Navigator.of(context).pop();
171-
setState(() {});
172-
},
173-
child: Text(
174-
AppLocalizations.of(context)!.save,
175-
),
176-
),
177-
),
178-
),
179-
Padding(
180-
padding: EdgeInsets.only(top: 7, bottom: 7),
181-
child: Container(
182-
width: double.infinity,
183-
height: 50,
184-
child: OutlinedButton(
185-
onPressed: () {
186-
Hive.box('settings').put(
187-
'officialApiKey',
188-
Constants().F1_API_KEY,
189-
);
190-
Navigator.of(context).pop();
191-
setState(() {});
192-
},
193-
child: Text(
194-
AppLocalizations.of(context)!.reset,
195-
),
196-
),
197-
),
198-
),
199-
Padding(
200-
padding: EdgeInsets.only(top: 7, bottom: 20),
201-
child: Container(
202-
width: double.infinity,
203-
height: 50,
204-
child: OutlinedButton(
205-
onPressed: () {
206-
Navigator.of(context).pop();
207-
},
208-
child: Text(
209-
AppLocalizations.of(context)!.close,
210-
),
211-
),
212-
),
213-
),
214-
],
215-
),
216-
),
217-
),
218-
);
219-
},
220-
trailing: Icon(
221-
Icons.key_outlined,
222-
),
223-
),
224109
if (championship == 'Formula 1')
225110
ListTile(
226111
title: Text(

0 commit comments

Comments
 (0)