Skip to content

Commit 9c3dabe

Browse files
committed
Show app version in settings
1 parent f818651 commit 9c3dabe

1 file changed

Lines changed: 59 additions & 37 deletions

File tree

lib/pages/settings.dart

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'dart:convert';
33
import 'package:flutter/foundation.dart';
44
import 'package:flutter/material.dart';
55
import 'package:flutter/services.dart';
6+
import 'package:package_info_plus/package_info_plus.dart';
67
import 'package:scouting_dashboard_app/constants.dart';
78
import 'package:scouting_dashboard_app/datatypes.dart';
89
import 'package:scouting_dashboard_app/pages/onboarding/onboarding_page.dart';
@@ -106,50 +107,71 @@ class _SettingsPageState extends State<SettingsPage> {
106107
const ResetAppButton(),
107108
if (lovatAPI.baseUrl != kProductionBaseUrl) ...[
108109
const SizedBox(height: 20),
109-
EmphasizedContainer(
110-
child: Column(
111-
crossAxisAlignment: CrossAxisAlignment.start,
112-
children: [
113-
// const SizedBox(width: 7),
114-
Text(
115-
"URL",
116-
style: Theme.of(context).textTheme.labelLarge,
117-
),
118-
Text(
119-
lovatAPI.baseUrl,
120-
maxLines: 1,
121-
overflow: TextOverflow.ellipsis,
122-
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
123-
color:
124-
Theme.of(context).colorScheme.onSurfaceVariant,
125-
),
126-
),
127-
const SizedBox(height: 10),
128-
FilledButton(
129-
onPressed: () async {
130-
final prefs = await SharedPreferences.getInstance();
131-
132-
await prefs.setString(
133-
'api_base_url', kProductionBaseUrl);
134-
135-
lovatAPI.baseUrl = kProductionBaseUrl;
136-
137-
Navigator.of(context).pushNamedAndRemoveUntil(
138-
"/loading", (route) => false);
139-
},
140-
style: const ButtonStyle(
141-
visualDensity: VisualDensity.compact),
142-
child: const Text("Use production"),
143-
),
144-
],
145-
))
110+
customApiConfig(context)
146111
],
112+
versionText(),
147113
],
148114
),
149115
],
150116
),
151117
);
152118
}
119+
120+
SizedBox versionText() {
121+
return SizedBox(
122+
height: 42,
123+
child: Center(
124+
child: FutureBuilder(
125+
future: PackageInfo.fromPlatform(),
126+
builder: (context, snapshot) => snapshot.hasData
127+
? Text(
128+
"Version ${snapshot.data!.version} • Build ${snapshot.data!.buildNumber}",
129+
style: Theme.of(context).textTheme.bodySmall?.copyWith(
130+
color: const Color(0xFFB8B8B8),
131+
),
132+
textAlign: TextAlign.center,
133+
)
134+
: Container()),
135+
),
136+
);
137+
}
138+
139+
EmphasizedContainer customApiConfig(BuildContext context) {
140+
return EmphasizedContainer(
141+
child: Column(
142+
crossAxisAlignment: CrossAxisAlignment.start,
143+
children: [
144+
// const SizedBox(width: 7),
145+
Text(
146+
"URL",
147+
style: Theme.of(context).textTheme.labelLarge,
148+
),
149+
Text(
150+
lovatAPI.baseUrl,
151+
maxLines: 1,
152+
overflow: TextOverflow.ellipsis,
153+
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
154+
color: Theme.of(context).colorScheme.onSurfaceVariant,
155+
),
156+
),
157+
const SizedBox(height: 10),
158+
FilledButton(
159+
onPressed: () async {
160+
final prefs = await SharedPreferences.getInstance();
161+
162+
await prefs.setString('api_base_url', kProductionBaseUrl);
163+
164+
lovatAPI.baseUrl = kProductionBaseUrl;
165+
166+
Navigator.of(context)
167+
.pushNamedAndRemoveUntil("/loading", (route) => false);
168+
},
169+
style: const ButtonStyle(visualDensity: VisualDensity.compact),
170+
child: const Text("Use production"),
171+
),
172+
],
173+
));
174+
}
153175
}
154176

155177
class TeamSourceSelector extends StatefulWidget {

0 commit comments

Comments
 (0)