Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit 36777e3

Browse files
committed
show server update status
1 parent fe886a3 commit 36777e3

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

lib/ui/pages/server_details_page/server_details_page.dart

+6-11
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
191191
isVacEnabled, isTvEnabled),
192192
ServerControls(widget.server, map, refreshInfo,
193193
sendCommandToSv, showToast, maps, numOfPlayers,
194-
maxPlayers, version, tvPort),
194+
maxPlayers, version, tvPort, isSvOutDated),
195195
PlayersList(players, refreshInfo, sendCommandToSv, showToast),
196196
if (players.isEmpty) EmptyServerState(),
197197
],
@@ -260,7 +260,7 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
260260
setState(() {
261261
isLoading = true;
262262
});
263-
_checkForSvUpdate();
263+
264264
_connectToServer((SourceServer sourceServer) async {
265265
final ServerInfo serverInfo = await sourceServer.getInfo();
266266
final String statusRes = await sourceServer.command('status');
@@ -282,21 +282,16 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
282282
isLoading = false;
283283
});
284284

285+
_checkForSvUpdate();
285286
sourceServer.close();
286287
});
287288
}
288289

289290
Future<void> _checkForSvUpdate () async {
290291
final dynamic svUpdateStatus = await checkForSvUpdate(version);
291-
print(svUpdateStatus['response']['up_to_date']);
292292

293-
if (svUpdateStatus['response']['up_to_date'] == 'true') {
294-
print('here');
295-
setState(() {
296-
isSvOutDated = false;
297-
});
298-
} else {
299-
isSvOutDated = true;
300-
}
293+
setState(() {
294+
isSvOutDated = svUpdateStatus['response']['up_to_date'] != true;
295+
});
301296
}
302297
}

lib/ui/widgets/server_widgets/server_controls.dart

+15-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:turrant/themes/styling.dart';
1010
class ServerControls extends StatelessWidget {
1111
const ServerControls(this.server, this.map, this.refreshInfo,
1212
this.sendCommandToSv, this.showToast, this.maps, this.numOfPlayers,
13-
this.maxPlayers, this.version, this.tvPort);
13+
this.maxPlayers, this.version, this.tvPort, this.isSvOutDated);
1414

1515
final Server server;
1616
final String map;
@@ -22,6 +22,7 @@ class ServerControls extends StatelessWidget {
2222
final String maxPlayers;
2323
final String version;
2424
final int tvPort;
25+
final bool isSvOutDated;
2526

2627
@override
2728
Widget build(BuildContext context) {
@@ -46,10 +47,10 @@ class ServerControls extends StatelessWidget {
4647
Row(
4748
crossAxisAlignment: CrossAxisAlignment.start,
4849
children: <Widget>[
49-
const Icon(Icons.map, color: AppStyles.blue2,
50-
size: 18
50+
const Icon(FontAwesomeIcons.solidMap, color: AppStyles.blue2,
51+
size: 16
5152
),
52-
const SizedBox(width: 8,),
53+
const SizedBox(width: 10,),
5354
Column(
5455
crossAxisAlignment: CrossAxisAlignment.start,
5556
children: <Widget>[
@@ -100,8 +101,9 @@ class ServerControls extends StatelessWidget {
100101
Row(
101102
crossAxisAlignment: CrossAxisAlignment.start,
102103
children: <Widget>[
103-
const Icon(Icons.tv, color: AppStyles.blue2, size: 18,),
104-
const SizedBox(width: 8,),
104+
const Icon(FontAwesomeIcons.tv,
105+
color: AppStyles.blue2, size: 16,),
106+
const SizedBox(width: 10,),
105107
Column(
106108
crossAxisAlignment: CrossAxisAlignment.start,
107109
children: <Widget>[
@@ -118,16 +120,19 @@ class ServerControls extends StatelessWidget {
118120
Row(
119121
crossAxisAlignment: CrossAxisAlignment.start,
120122
children: <Widget>[
121-
const Icon(FontAwesomeIcons.codeBranch,
122-
color: AppStyles.blue2, size: 18),
123-
const SizedBox(width: 8,),
123+
if (!isSvOutDated) const Icon(FontAwesomeIcons.codeBranch,
124+
color: AppStyles.blue2, size: 16)
125+
else const Icon(FontAwesomeIcons.exclamationTriangle,
126+
color: AppStyles.yellow, size: 16
127+
),
128+
const SizedBox(width: 10,),
124129
Column(
125130
crossAxisAlignment: CrossAxisAlignment.start,
126131
children: <Widget>[
127132
Text(version,
128133
style: AppStyles.serverDetailsHeaderTitle,),
129134
const SizedBox(height: 2,),
130-
const Text('Server Version',
135+
Text(isSvOutDated ? 'Update available!' : 'Up to Date',
131136
style: AppStyles.consoleRes),
132137
],
133138
),

0 commit comments

Comments
 (0)