Made the Server Entries Selectable #12
1 changed files with 112 additions and 66 deletions
|
@ -28,6 +28,7 @@ class ServerList extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ServerListState extends State<ServerList> {
|
class _ServerListState extends State<ServerList> {
|
||||||
|
int selectedServer = -1;
|
||||||
List<Server> servers = [
|
List<Server> servers = [
|
||||||
new Server(
|
new Server(
|
||||||
"example.com",
|
"example.com",
|
||||||
|
@ -66,6 +67,7 @@ class _ServerListState extends State<ServerList> {
|
||||||
|
|
||||||
void _updateServerStatus(Server s) {
|
void _updateServerStatus(Server s) {
|
||||||
checkStatus(s.uri).then((value) {
|
checkStatus(s.uri).then((value) {
|
||||||
|
if (value != s.status)
|
||||||
setState(() {
|
setState(() {
|
||||||
s.status = value;
|
s.status = value;
|
||||||
});
|
});
|
||||||
|
@ -112,14 +114,17 @@ class _ServerListState extends State<ServerList> {
|
||||||
children: _createChildren(),
|
children: _createChildren(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: SpeedDial(
|
floatingActionButton: FloatingActionButton(
|
||||||
|
shape: CircleBorder(),
|
||||||
|
child: Icon(Icons.settings),
|
||||||
|
)
|
||||||
|
/*SpeedDial(
|
||||||
animatedIcon: AnimatedIcons.menu_close,
|
animatedIcon: AnimatedIcons.menu_close,
|
||||||
animatedIconTheme: IconThemeData(size: 20.0),
|
animatedIconTheme: IconThemeData(size: 20.0),
|
||||||
animationSpeed: 150,
|
animationSpeed: 50,
|
||||||
tooltip: 'Menu',
|
tooltip: 'Menu',
|
||||||
backgroundColor: Colors.red.shade900,
|
backgroundColor: Colors.red.shade900,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
elevation: 1.0,
|
|
||||||
shape: CircleBorder(),
|
shape: CircleBorder(),
|
||||||
children: [
|
children: [
|
||||||
SpeedDialChild(
|
SpeedDialChild(
|
||||||
|
@ -138,30 +143,20 @@ class _ServerListState extends State<ServerList> {
|
||||||
labelStyle: TextStyle(fontSize: 18.0),
|
labelStyle: TextStyle(fontSize: 18.0),
|
||||||
onTap: _addServer,
|
onTap: _addServer,
|
||||||
),
|
),
|
||||||
],
|
],*/
|
||||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
// This trailing comma makes auto-formatting nicer for build methods.
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _settings() {}
|
void _settings() {}
|
||||||
|
|
||||||
void _addServer(){}
|
void _addServer() {
|
||||||
|
print('poop');
|
||||||
|
}
|
||||||
|
|
||||||
List<Widget> _createChildren() {
|
List<Widget> _createChildren() {
|
||||||
return new List<Widget>.generate(servers.length, (int index) {
|
List<Widget> list = new List<Widget>.generate(servers.length, (int index) {
|
||||||
return Container(
|
Widget info = Row(children: [
|
||||||
height: 75,
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
margin: EdgeInsets.all(2.0),
|
|
||||||
padding: EdgeInsets.all(10.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white70,
|
|
||||||
border: Border.all(
|
|
||||||
color: Colors.grey,
|
|
||||||
width: 1,
|
|
||||||
)),
|
|
||||||
child: Row(children: [
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
|
@ -172,19 +167,70 @@ class _ServerListState extends State<ServerList> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
width: 75,
|
width: 50,
|
||||||
|
height: 50,
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: _generateIcon(servers[index]),
|
child: _generateIcon(servers[index]),
|
||||||
// child: Text(
|
|
||||||
// status[index],
|
|
||||||
// style: TextStyle(fontSize: 24),
|
|
||||||
// ),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]),
|
]);
|
||||||
|
if (index == selectedServer) {
|
||||||
|
info = Column(
|
||||||
|
children: [
|
||||||
|
info,
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(border: Border(top: BorderSide(color: Colors.grey))),
|
||||||
|
),
|
||||||
|
Text('Ping: 1111'),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
selectedServer = index;
|
||||||
|
});
|
||||||
|
print(index.toString() + " clicked");
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
margin: EdgeInsets.all(2.0),
|
||||||
|
padding: EdgeInsets.all(10.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white70,
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.grey,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: info),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
list.add(
|
||||||
|
Container(
|
||||||
|
height: 75,
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
margin: EdgeInsets.all(2.0),
|
||||||
|
padding: EdgeInsets.all(10.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white70,
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.grey,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.add,
|
||||||
|
size: 42,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
onPressed: _addServer,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<ServerStatus> checkStatus(String uri) async {
|
static Future<ServerStatus> checkStatus(String uri) async {
|
||||||
|
|
Loading…
Reference in a new issue