From 1b34af516448a9fe07f2238272edfb949700af37 Mon Sep 17 00:00:00 2001 From: Hugo Bayer Date: Tue, 28 Jan 2020 12:08:48 +0100 Subject: [PATCH] added speed dial and changed the main colors --- lib/main.dart | 2 +- lib/serverlist.dart | 47 +++++++++++++++++++++++++++++++++++---------- pubspec.yaml | 3 +++ 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 0fefd86..5985578 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,7 +20,7 @@ class MyApp extends StatelessWidget { // or simply save your changes to "hot reload" in a Flutter IDE). // Notice that the counter didn't reset back to zero; the application // is not restarted. - primarySwatch: Colors.red, + primaryColor: Colors.red.shade900 ), home: ServerList(title: 'Server list'), ); diff --git a/lib/serverlist.dart b/lib/serverlist.dart index 276a6ae..12c5507 100644 --- a/lib/serverlist.dart +++ b/lib/serverlist.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:basic_utils/basic_utils.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_speed_dial/flutter_speed_dial.dart'; import 'package:server_pinger/server.dart'; import 'server.dart'; @@ -54,21 +55,19 @@ class _ServerListState extends State { super.initState(); _updateAllServers(); - timer = new Timer.periodic(new Duration(seconds: 5), (timer) { + timer = new Timer.periodic(new Duration(seconds: 30), (timer) { _updateAllServers(); }); } - Future _updateAllServers() async { + void _updateAllServers() async { servers.forEach(_updateServerStatus); } - void _updateServerStatus(Server s) async { + void _updateServerStatus(Server s) { checkStatus(s.uri).then((value) { setState(() { - checkStatus(s.uri).then((value){ - s.status=value; - }); + s.status = value; }); }); } @@ -113,14 +112,42 @@ class _ServerListState extends State { children: _createChildren(), ), ), - floatingActionButton: FloatingActionButton( - onPressed: _updateUI, - tooltip: 'Increment', - child: Icon(Icons.add), + floatingActionButton: SpeedDial( + animatedIcon: AnimatedIcons.menu_close, + animatedIconTheme: IconThemeData(size: 20.0), + 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. ); } + + void _settings() {} + + void _addServer(){} + List _createChildren() { return new List.generate(servers.length, (int index) { return Container( diff --git a/pubspec.yaml b/pubspec.yaml index 6b82c4d..bc3050f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,7 +24,10 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.3 + # Needed for DNS lookup basic_utils: ^2.4.8 + # Needed for FAB menu + flutter_speed_dial: ^1.2.5 dev_dependencies: flutter_test: -- 2.47.0