Skip to content

Commit c60f25d

Browse files
committed
feat: custom ergast-compliant api url; remove video tab to f1 series
1 parent e935de9 commit c60f25d

34 files changed

+2273
-231
lines changed

lib/Screens/Settings/championship.dart

Lines changed: 66 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* Copyright (c) 2022-2025, BrightDV
1818
*/
1919

20+
import 'package:boxbox/helpers/bottom_sheet.dart';
2021
import 'package:boxbox/helpers/constants.dart';
2122
import 'package:boxbox/l10n/app_localizations.dart';
2223
import 'package:cached_network_image/cached_network_image.dart';
@@ -101,77 +102,77 @@ class _ChampionshipScreenState extends State<ChampionshipScreen> {
101102
onPressed: () async {
102103
final TextEditingController controller =
103104
TextEditingController();
104-
await showModalBottomSheet(
105-
context: context,
106-
builder: (context) => BottomSheet(
107-
shape: RoundedRectangleBorder(
108-
borderRadius: BorderRadius.circular(10.0),
109-
),
110-
onClosing: () {},
111-
builder: (context) {
112-
return SizedBox(
113-
child: Padding(
114-
padding: EdgeInsets.fromLTRB(
115-
30,
116-
15,
117-
30,
118-
MediaQuery.of(context).viewInsets.bottom,
105+
await showCustomBottomSheet(
106+
context,
107+
SizedBox(
108+
child: Padding(
109+
padding: EdgeInsets.fromLTRB(
110+
30,
111+
15,
112+
30,
113+
MediaQuery.of(context).viewInsets.bottom,
114+
),
115+
child: Column(
116+
mainAxisSize: MainAxisSize.min,
117+
children: [
118+
Padding(
119+
padding: EdgeInsets.only(bottom: 20),
120+
child: Text(
121+
AppLocalizations.of(context)!
122+
.customErgastUrl,
123+
style: TextStyle(fontSize: 20),
124+
),
119125
),
120-
child: Column(
121-
mainAxisSize: MainAxisSize.min,
122-
children: [
123-
TextField(
124-
controller: controller,
125-
decoration: InputDecoration(
126-
hintText: ergastUrl,
127-
hintStyle: TextStyle(
128-
fontWeight: FontWeight.w100,
129-
),
130-
),
126+
TextField(
127+
controller: controller,
128+
decoration: InputDecoration(
129+
border: OutlineInputBorder(),
130+
hintText: ergastUrl,
131+
hintStyle: TextStyle(
132+
fontWeight: FontWeight.w100,
131133
),
132-
Padding(
133-
padding: EdgeInsets.only(
134-
top: 5,
135-
bottom: 5,
134+
),
135+
),
136+
Padding(
137+
padding:
138+
EdgeInsets.only(top: 20, bottom: 7),
139+
child: Container(
140+
width: double.infinity,
141+
height: 50,
142+
child: FilledButton.tonal(
143+
onPressed: () {
144+
Hive.box('settings').put(
145+
'ergastUrl',
146+
controller.text,
147+
);
148+
Navigator.of(context).pop();
149+
setState(() {});
150+
},
151+
child: Text(
152+
AppLocalizations.of(context)!.save,
136153
),
137-
child: Row(
138-
children: [
139-
ElevatedButton(
140-
onPressed: () {
141-
Hive.box('settings').put(
142-
'ergastUrl',
143-
controller.text,
144-
);
145-
Navigator.of(context).pop();
146-
setState(() {});
147-
},
148-
child: Text(
149-
AppLocalizations.of(context)!
150-
.save,
151-
),
152-
),
153-
Padding(
154-
padding:
155-
EdgeInsets.only(left: 10),
156-
child: ElevatedButton(
157-
onPressed: () {
158-
Navigator.of(context).pop();
159-
},
160-
child: Text(
161-
AppLocalizations.of(
162-
context)!
163-
.close,
164-
),
165-
),
166-
),
167-
],
154+
),
155+
),
156+
),
157+
Padding(
158+
padding:
159+
EdgeInsets.only(top: 7, bottom: 20),
160+
child: Container(
161+
width: double.infinity,
162+
height: 50,
163+
child: OutlinedButton(
164+
onPressed: () {
165+
Navigator.of(context).pop();
166+
},
167+
child: Text(
168+
AppLocalizations.of(context)!.close,
168169
),
169170
),
170-
],
171+
),
171172
),
172-
),
173-
);
174-
},
173+
],
174+
),
175+
),
175176
),
176177
);
177178
},

lib/api/ergast.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import 'package:hive_flutter/hive_flutter.dart';
2929
import 'package:http/http.dart' as http;
3030

3131
class _ErgastApiCalls {
32-
final String defaultEndpoint = Constants().ERGAST_API_URL;
32+
final String defaultEndpoint = Constants().getErgastUrl();
3333
List<DriverResult> formatRaceStandings(Map raceStandings) {
3434
List<DriverResult> formatedRaceStandings = [];
3535
List jsonResponse =

lib/helpers/bottom_sheet.dart

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* This file is part of BoxBox (https://github.com/BrightDV/BoxBox).
3+
*
4+
* BoxBox is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* BoxBox is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with BoxBox. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* Copyright (c) 2022-2025, BrightDV
18+
*/
19+
20+
import 'package:flutter/material.dart';
21+
22+
Future<void> showCustomBottomSheet(BuildContext context, Widget builder) async {
23+
await showModalBottomSheet(
24+
context: context,
25+
builder: (context) => CustomBottomSheet(builder),
26+
);
27+
}
28+
29+
class CustomBottomSheet extends StatelessWidget {
30+
final Widget builder;
31+
const CustomBottomSheet(this.builder, {super.key});
32+
33+
@override
34+
Widget build(BuildContext context) {
35+
return BottomSheet(
36+
shape: RoundedRectangleBorder(
37+
borderRadius: BorderRadius.only(
38+
topLeft: Radius.circular(10.0),
39+
topRight: Radius.circular(10.0),
40+
),
41+
),
42+
onClosing: () {},
43+
builder: (context) => builder,
44+
);
45+
}
46+
}

lib/helpers/constants.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,10 @@ class Constants {
9696
.get('officialApiKey', defaultValue: F1_API_KEY) as String;
9797
return apiKey;
9898
}
99+
100+
String getErgastUrl() {
101+
String ergastUrl = Hive.box('settings')
102+
.get('ergastUrl', defaultValue: ERGAST_API_URL) as String;
103+
return ergastUrl;
104+
}
99105
}

lib/l10n/app_en.arb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
"@country": {},
5858
"crashError": "Error:",
5959
"@crashError": {},
60+
"customErgastUrl": "Ergast Custom URL",
61+
"@customErgastUrl": {},
6062
"customFeed": "Custom feed",
6163
"@customFeed": {},
6264
"customHomeFeed": "Custom home feed",

lib/l10n/app_fr.arb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
"@country": {},
5858
"crashError": "Erreur :",
5959
"@crashError": {},
60+
"customErgastUrl": "Ergast URL personnalisée",
61+
"@customErgastUrl": {},
6062
"customFeed": "Flux personnalisé",
6163
"@customFeed": {},
6264
"customHomeFeed": "Flux d'accueil personnalisé",

0 commit comments

Comments
 (0)