This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ServerInfo { | |
public final String name; | |
public final List<ServiceInfo> services; | |
public ServerInfo(String name, List<ServiceInfo> services) { | |
this.name = name; | |
this.services = services; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ServiceInfo { | |
public final String name; | |
public final boolean running; | |
public ServiceInfo(String name, boolean running) { | |
this.name = name; | |
this.running = running; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<ServerInfo> getServerInfo() { | |
List<ServerInfo> result = new ArrayList<>(); | |
Map<String, String> serverData = getServerData(); | |
for (Map.Entry<String, String> info : serverData.entrySet()) { | |
result.add(new ServerInfo(info.getKey(), map(info.getValue()))); | |
} | |
return result; | |
} | |
private static List<ServiceInfo> map(String data) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ServiceInfo { | |
const ServiceInfo({this.name, this.running}); | |
final String name; | |
final bool running; | |
String status() { | |
if (running) { | |
return "running"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget _buildGridView(BuildContext context, List<ServerInfo> serverInfo) { | |
return GridView.count( | |
primary: false, | |
padding: const EdgeInsets.all(1.5), | |
crossAxisCount: determineCrossAxisCount(context), | |
childAspectRatio: 1.2, | |
mainAxisSpacing: 1.0, | |
crossAxisSpacing: 1.0, | |
children: _prepareServerInfoCards(serverInfo), //new Cards() | |
shrinkWrap: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
int determineCrossAxisCount(BuildContext context) { | |
int _crossAxisCount = 1; | |
final double screenWidthSize = MediaQuery.of(context).size.width; | |
if (screenWidthSize > 820) { | |
_crossAxisCount = 4; | |
} else if (screenWidthSize > 720) { | |
_crossAxisCount = 3; | |
} else if (screenWidthSize > 520) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Widget> _prepareServerInfoCards(List<ServerInfo> serverInfo) { | |
List<Widget> serverInfoCells = []; | |
// we can call the rest service here? | |
for (ServerInfo category in serverInfo) { | |
serverInfoCells.add(_getServerInfoCard(category)); | |
} | |
return serverInfoCells; | |
} | |
Container _getServerInfoCard(ServerInfo serverInfo) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget _createStatusTable(ServerInfo serverInfo) { | |
if (serverInfo.notAvailable()) { | |
return new Text('Server unreachable'); | |
} | |
return Table( | |
border: TableBorder.all( | |
color: Colors.black26, width: 1, style: BorderStyle.none), | |
children: _createStatusCells(serverInfo.services)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TextStyle _getStyleByServiceStatus(bool running) { | |
if (!running) { | |
return TextStyle(fontStyle: FontStyle.italic); | |
} | |
return TextStyle(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Color _getColorByServerStatus(ServerInfo info) { | |
if (info.running()) { | |
return Colors.teal[600]; | |
} else { | |
return Colors.red[200]; | |
} | |
} |
OlderNewer