From af1cc22d8694c4ea266456237bd837225b7ab995 Mon Sep 17 00:00:00 2001 From: Aguilaair Date: Mon, 10 Aug 2020 18:04:07 +0200 Subject: [PATCH] implementation of better brand guidelines (text box is now similar to dashboard) --- lib/pages/deployPage.dart | 2 +- lib/widget/SSIDInput.dart | 120 +++++++++----------------------------- lib/widget/textInput.dart | 23 ++++++-- 3 files changed, 48 insertions(+), 97 deletions(-) diff --git a/lib/pages/deployPage.dart b/lib/pages/deployPage.dart index 3258306..a5eda94 100644 --- a/lib/pages/deployPage.dart +++ b/lib/pages/deployPage.dart @@ -57,7 +57,7 @@ class _DeployPageState extends State { Container( width: MediaQuery.of(context).size.width, child: Text( - "Sign Up", + "Set wifi", textAlign: TextAlign.left, style: TextStyle( fontSize: 30, diff --git a/lib/widget/SSIDInput.dart b/lib/widget/SSIDInput.dart index cd16233..a4419e9 100644 --- a/lib/widget/SSIDInput.dart +++ b/lib/widget/SSIDInput.dart @@ -1,6 +1,7 @@ import 'package:connectivity/connectivity.dart'; import 'package:flutter/material.dart'; import 'package:gategoDeploy/controller/WifiInfo.dart'; +import 'package:gategoDeploy/widget/textInput.dart'; import 'package:location_permissions/location_permissions.dart'; import 'package:get/get.dart'; @@ -48,101 +49,38 @@ class _SSIDInputState extends State { Widget build(BuildContext context) { return Column( children: [ - Padding( - padding: const EdgeInsets.only(top: 50, left: 10, right: 10), - child: Row( - children: [ - Expanded( - child: TextField( - onChanged: (val) => c.setSSID(val), - controller: controller, - style: TextStyle( - color: Theme.of(context).primaryColor, - ), - decoration: InputDecoration( - focusColor: Theme.of(context).primaryColor, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(15), - borderSide: BorderSide( - color: Theme.of(context).primaryColor, - width: 1, - style: BorderStyle.solid), - ), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(15), - borderSide: BorderSide( - color: Theme.of(context).primaryColor, - width: 1, - style: BorderStyle.solid), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(15), - borderSide: BorderSide( - color: Theme.of(context).primaryColor, - width: 1, - style: BorderStyle.solid), - ), - fillColor: Colors.lightBlueAccent, - labelText: 'Network Name', - labelStyle: TextStyle( - color: Theme.of(context).primaryColor, - ), - ), - ), - ), - IconButton( - icon: Icon( - Icons.sync, - color: Theme.of(context).primaryColor, - size: 30, - ), - onPressed: () => wifi(), - ) - ], - ), + SizedBox( + height: 50, ), - Padding( - padding: const EdgeInsets.only(top: 20, left: 10, right: 10), - child: Container( - height: 60, - width: MediaQuery.of(context).size.width, - child: TextField( - onChanged: (val) => c.setPSK(val), - style: TextStyle( - color: Theme.of(context).primaryColor, - ), - obscureText: true, - decoration: InputDecoration( - focusColor: Theme.of(context).primaryColor, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(15), - borderSide: BorderSide( - color: Theme.of(context).primaryColor, - width: 1, - style: BorderStyle.solid), - ), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(15), - borderSide: BorderSide( - color: Theme.of(context).primaryColor, - width: 1, - style: BorderStyle.solid), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(15), - borderSide: BorderSide( - color: Theme.of(context).primaryColor, - width: 1, - style: BorderStyle.solid), - ), - labelText: 'Password', - labelStyle: TextStyle( - color: Theme.of(context).primaryColor, - ), + Row( + children: [ + Expanded( + child: TextInput( + setData: c.setSSID, + icon: Icons.wifi, + text: "Network Name", + c: controller, ), ), - ), + IconButton( + icon: Icon( + Icons.sync, + color: Theme.of(context).primaryColor, + size: 30, + ), + onPressed: () => wifi(), + ) + ], + ), + SizedBox( + height: 20, ), + TextInput( + setData: c.setPSK, + icon: Icons.vpn_key, + text: "Password", + obscureText: true, + ) ], ); } diff --git a/lib/widget/textInput.dart b/lib/widget/textInput.dart index 2eccc6c..a969e62 100644 --- a/lib/widget/textInput.dart +++ b/lib/widget/textInput.dart @@ -2,7 +2,18 @@ import 'package:flutter/material.dart'; class TextInput extends StatefulWidget { final Function setData; - const TextInput(this.setData, {Key key}) : super(key: key); + final TextEditingController c; + final IconData icon; + final String text; + final bool obscureText; + const TextInput( + {this.setData, + this.icon, + this.text, + this.obscureText = false, + Key key, + this.c}) + : super(key: key); @override _TextInputState createState() => _TextInputState(); @@ -41,13 +52,12 @@ class _TextInputState extends State { @override void dispose() { super.dispose(); - controller.dispose(); _focusNode.dispose(); } @override Widget build(BuildContext context) { - final padding = 16.0; + final padding = 8.0; var size = MediaQuery.of(context).size.width - padding * 2; return Center( child: Padding( @@ -72,7 +82,7 @@ class _TextInputState extends State { width: 10, ), Icon( - Icons.wifi, + widget.icon, size: 25, color: colorIcon, ), @@ -82,14 +92,17 @@ class _TextInputState extends State { borderRadius: BorderRadius.horizontal(right: Radius.circular(15)), child: TextField( + controller: widget.c, focusNode: _focusNode, + obscureText: widget.obscureText, + onChanged: widget.setData, decoration: InputDecoration( fillColor: Color(0xfff5f5f5), focusColor: Color(0xfff5f5f5), hoverColor: Color(0xfff5f5f5), filled: true, border: InputBorder.none, - hintText: "Network", + hintText: widget.text, hintStyle: TextStyle( color: Color(0xff727272), fontWeight: FontWeight.w300),