added speed dial and changed the main colors #11
3 changed files with 41 additions and 11 deletions
|
@ -20,7 +20,7 @@ class MyApp extends StatelessWidget {
|
||||||
// or simply save your changes to "hot reload" in a Flutter IDE).
|
// or simply save your changes to "hot reload" in a Flutter IDE).
|
||||||
// Notice that the counter didn't reset back to zero; the application
|
// Notice that the counter didn't reset back to zero; the application
|
||||||
// is not restarted.
|
// is not restarted.
|
||||||
primarySwatch: Colors.red,
|
primaryColor: Colors.red.shade900
|
||||||
),
|
),
|
||||||
home: ServerList(title: 'Server list'),
|
home: ServerList(title: 'Server list'),
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:basic_utils/basic_utils.dart';
|
import 'package:basic_utils/basic_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
import 'package:server_pinger/server.dart';
|
import 'package:server_pinger/server.dart';
|
||||||
|
|
||||||
import 'server.dart';
|
import 'server.dart';
|
||||||
|
@ -54,21 +55,19 @@ class _ServerListState extends State<ServerList> {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
_updateAllServers();
|
_updateAllServers();
|
||||||
timer = new Timer.periodic(new Duration(seconds: 5), (timer) {
|
timer = new Timer.periodic(new Duration(seconds: 30), (timer) {
|
||||||
_updateAllServers();
|
_updateAllServers();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _updateAllServers() async {
|
void _updateAllServers() async {
|
||||||
servers.forEach(_updateServerStatus);
|
servers.forEach(_updateServerStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateServerStatus(Server s) async {
|
void _updateServerStatus(Server s) {
|
||||||
checkStatus(s.uri).then((value) {
|
checkStatus(s.uri).then((value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
checkStatus(s.uri).then((value){
|
s.status = value;
|
||||||
s.status=value;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -113,14 +112,42 @@ class _ServerListState extends State<ServerList> {
|
||||||
children: _createChildren(),
|
children: _createChildren(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: SpeedDial(
|
||||||
onPressed: _updateUI,
|
animatedIcon: AnimatedIcons.menu_close,
|
||||||
tooltip: 'Increment',
|
animatedIconTheme: IconThemeData(size: 20.0),
|
||||||
child: Icon(Icons.add),
|
animationSpeed: 150,
|
||||||
|
tooltip: 'Menu',
|
||||||
|
backgroundColor: Colors.red.shade900,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
elevation: 1.0,
|
||||||
|
shape: CircleBorder(),
|
||||||
|
children: [
|
||||||
|
SpeedDialChild(
|
||||||
|
child: Icon(Icons.settings),
|
||||||
|
label: 'Settings',
|
||||||
|
backgroundColor: Colors.red.shade600,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
labelStyle: TextStyle(fontSize: 18.0),
|
||||||
|
onTap: _settings,
|
||||||
|
),
|
||||||
|
SpeedDialChild(
|
||||||
|
child: Icon(Icons.add),
|
||||||
|
label: 'Add server',
|
||||||
|
backgroundColor: Colors.red.shade600,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
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(){}
|
||||||
|
|
||||||
List<Widget> _createChildren() {
|
List<Widget> _createChildren() {
|
||||||
return new List<Widget>.generate(servers.length, (int index) {
|
return new List<Widget>.generate(servers.length, (int index) {
|
||||||
return Container(
|
return Container(
|
||||||
|
|
|
@ -24,7 +24,10 @@ dependencies:
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^0.1.3
|
cupertino_icons: ^0.1.3
|
||||||
|
|
||||||
|
# Needed for DNS lookup
|
||||||
basic_utils: ^2.4.8
|
basic_utils: ^2.4.8
|
||||||
|
# Needed for FAB menu
|
||||||
|
flutter_speed_dial: ^1.2.5
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in a new issue