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> {
|
||||
int selectedServer = -1;
|
||||
List<Server> servers = [
|
||||
new Server(
|
||||
"example.com",
|
||||
|
@ -66,6 +67,7 @@ class _ServerListState extends State<ServerList> {
|
|||
|
||||
void _updateServerStatus(Server s) {
|
||||
checkStatus(s.uri).then((value) {
|
||||
if (value != s.status)
|
||||
setState(() {
|
||||
s.status = value;
|
||||
});
|
||||
|
@ -112,14 +114,17 @@ class _ServerListState extends State<ServerList> {
|
|||
children: _createChildren(),
|
||||
),
|
||||
),
|
||||
floatingActionButton: SpeedDial(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
shape: CircleBorder(),
|
||||
child: Icon(Icons.settings),
|
||||
)
|
||||
/*SpeedDial(
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
animatedIconTheme: IconThemeData(size: 20.0),
|
||||
animationSpeed: 150,
|
||||
animationSpeed: 50,
|
||||
tooltip: 'Menu',
|
||||
backgroundColor: Colors.red.shade900,
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 1.0,
|
||||
shape: CircleBorder(),
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
|
@ -138,30 +143,20 @@ class _ServerListState extends State<ServerList> {
|
|||
labelStyle: TextStyle(fontSize: 18.0),
|
||||
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 _addServer(){}
|
||||
void _addServer() {
|
||||
print('poop');
|
||||
}
|
||||
|
||||
List<Widget> _createChildren() {
|
||||
return new List<Widget>.generate(servers.length, (int index) {
|
||||
return 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: Row(children: [
|
||||
List<Widget> list = new List<Widget>.generate(servers.length, (int index) {
|
||||
Widget info = Row(children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
|
@ -172,19 +167,70 @@ class _ServerListState extends State<ServerList> {
|
|||
),
|
||||
),
|
||||
Container(
|
||||
width: 75,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue