diff --git a/lib/screens/auth.dart b/lib/screens/auth.dart index a8200be..7870cc1 100644 --- a/lib/screens/auth.dart +++ b/lib/screens/auth.dart @@ -5,7 +5,6 @@ import 'package:outbag_app/tools/fetch_wrapper.dart'; import 'package:outbag_app/tools/snackbar.dart'; import 'package:routemaster/routemaster.dart'; import '../backend/resolve_url.dart'; -import '../backend/errors.dart'; import 'package:crypto/crypto.dart'; import 'dart:convert'; @@ -70,105 +69,106 @@ class _AuthPageState extends State { ), ), body: Center( - child: Flexible( - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 400), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: _ctrServer, - keyboardType: TextInputType.url, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.dns), - labelText: 'Server', - hintText: 'Your homeserver url', - helperText: - 'Your data will be stored on your homeserver', - border: OutlineInputBorder(), - ), - ), + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 400), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: _ctrServer, + keyboardType: TextInputType.url, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.dns), + labelText: 'Server', + hintText: 'Your homeserver url', + helperText: + 'Your data will be stored on your homeserver', + border: OutlineInputBorder(), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: _ctrUsername, + keyboardType: TextInputType.emailAddress, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.person), + labelText: 'Username', + hintText: 'Your username', + helperText: + 'your username and server tag allow others to identify you', + border: OutlineInputBorder(), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: _ctrPassword, + keyboardType: TextInputType.visiblePassword, + obscureText: true, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.lock), + labelText: 'Password', + hintText: 'Your password', + helperText: + 'Password have to be at least six characters long', + border: OutlineInputBorder(), + ), + ), + ), + // ONLY SIGNUP + ...((widget.mode != Mode.signin) + ? [ + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: _ctrPasswordRpt, + keyboardType: + TextInputType.visiblePassword, + obscureText: true, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.lock), + labelText: 'Repeat Password', + hintText: 'Type your password again', + helperText: + 'Make sure to type the correct password', + border: OutlineInputBorder(), ), - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: _ctrUsername, - keyboardType: TextInputType.emailAddress, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.person), - labelText: 'Username', - hintText: 'Your username', - helperText: - 'your username and server tag allow others to identify you', - border: OutlineInputBorder(), - ), - ), + ), + ) + ] + : []), + // ONLY SIGNUP OTA + ...((widget.mode == Mode.signupOTA) + ? [ + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: _ctrOTA, + keyboardType: + TextInputType.visiblePassword, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.key), + labelText: 'OTA', + hintText: + 'One-Time-Authorization token', + helperText: + 'This token might be required if the server is rate limited', + border: OutlineInputBorder(), ), - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: _ctrPassword, - keyboardType: TextInputType.visiblePassword, - obscureText: true, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.lock), - labelText: 'Password', - hintText: 'Your password', - helperText: - 'Password have to be at least six characters long', - border: OutlineInputBorder(), - ), - ), - ), - // ONLY SIGNUP - ...((widget.mode != Mode.signin) - ? [ - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: _ctrPasswordRpt, - keyboardType: - TextInputType.visiblePassword, - obscureText: true, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.lock), - labelText: 'Repeat Password', - hintText: 'Type your password again', - helperText: - 'Make sure to type the correct password', - border: OutlineInputBorder(), - ), - ), - ) - ] - : []), - // ONLY SIGNUP OTA - ...((widget.mode == Mode.signupOTA) - ? [ - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: _ctrOTA, - keyboardType: - TextInputType.visiblePassword, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.key), - labelText: 'OTA', - hintText: - 'One-Time-Authorization token', - helperText: - 'This token might be required if the server is rate limited', - border: OutlineInputBorder(), - ), - ), - ) - ] - : []), - ], - )))), + ), + ) + ] + : []), + ], + ) + ) + ), floatingActionButton: FloatingActionButton.extended( onPressed: () async { setState(() { diff --git a/lib/screens/room/edit.dart b/lib/screens/room/edit.dart index 200ad6e..2b09911 100644 --- a/lib/screens/room/edit.dart +++ b/lib/screens/room/edit.dart @@ -140,105 +140,106 @@ class _EditRoomPageState extends State { ), ), body: Center( - child: Flexible( - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 400), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - IconButton( - icon: SvgPicture.asset( - _ctrIcon.img, - width: smallest * 0.3, - height: smallest * 0.3, - ), - tooltip: 'Change room icon', - onPressed: () { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: - const Text('Choose a room Icon'), - actions: const [], - content: SizedBox( - width: smallest * 0.3 * 3, - height: smallest * 0.3 * 3, - child: GridView.count( - crossAxisCount: 3, - children: RoomIcon.list() - .map((icon) { - return GridTile( - child: IconButton( - icon: SvgPicture - .asset( - icon.img, - width: smallest * - 0.3, - height: smallest * - 0.3, - ), - tooltip: icon.text, - onPressed: () { - setState(() { - _ctrIcon = icon; - }); - Navigator.of( - context) - .pop(); - })); - }).toList())), - )); - }, - ), - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - enabled: false, - controller: _ctrID, - keyboardType: TextInputType.emailAddress, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.fact_check), - labelText: 'Room ID', - hintText: 'Unique room id', - helperText: - 'the room id and server tag allow the room to be identified', - border: OutlineInputBorder(), - ), - ), - ), - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: _ctrName, - keyboardType: TextInputType.name, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.badge), - labelText: 'Room Name', - hintText: 'Give your room a name', - helperText: - 'Easily identify a room with a human readable name', - border: OutlineInputBorder(), - ), - ), - ), - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: _ctrDescription, - keyboardType: TextInputType.text, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.dns), - labelText: 'Room Description', - hintText: 'Briefly describe your Room', - helperText: - 'Make it easier for other to know what this room is used for', - border: OutlineInputBorder(), - ), - ), - ), - ], - )))), + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 400), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + IconButton( + icon: SvgPicture.asset( + _ctrIcon.img, + width: smallest * 0.3, + height: smallest * 0.3, + ), + tooltip: 'Change room icon', + onPressed: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: + const Text('Choose a room Icon'), + actions: const [], + content: SizedBox( + width: smallest * 0.3 * 3, + height: smallest * 0.3 * 3, + child: GridView.count( + crossAxisCount: 3, + children: RoomIcon.list() + .map((icon) { + return GridTile( + child: IconButton( + icon: SvgPicture + .asset( + icon.img, + width: smallest * + 0.3, + height: smallest * + 0.3, + ), + tooltip: icon.text, + onPressed: () { + setState(() { + _ctrIcon = icon; + }); + Navigator.of( + context) + .pop(); + })); + }).toList())), + )); + }, + ), + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + enabled: false, + controller: _ctrID, + keyboardType: TextInputType.emailAddress, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.fact_check), + labelText: 'Room ID', + hintText: 'Unique room id', + helperText: + 'the room id and server tag allow the room to be identified', + border: OutlineInputBorder(), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: _ctrName, + keyboardType: TextInputType.name, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.badge), + labelText: 'Room Name', + hintText: 'Give your room a name', + helperText: + 'Easily identify a room with a human readable name', + border: OutlineInputBorder(), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: _ctrDescription, + keyboardType: TextInputType.text, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.dns), + labelText: 'Room Description', + hintText: 'Briefly describe your Room', + helperText: + 'Make it easier for other to know what this room is used for', + border: OutlineInputBorder(), + ), + ), + ), + ], + ) + ) + ), floatingActionButton: FloatingActionButton.extended( onPressed: () async { final scaffMgr = ScaffoldMessenger.of(context); diff --git a/lib/screens/room/new.dart b/lib/screens/room/new.dart index cae3a20..e01ecd1 100644 --- a/lib/screens/room/new.dart +++ b/lib/screens/room/new.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:outbag_app/backend/errors.dart'; import 'package:outbag_app/backend/request.dart'; import 'package:outbag_app/backend/room.dart'; import 'package:outbag_app/backend/user.dart'; @@ -58,125 +57,126 @@ class _NewRoomPageState extends State { ), ), body: Center( - child: Flexible( - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 400), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - IconButton( - icon: SvgPicture.asset( - _ctrIcon.img, - width: smallest * 0.3, - height: smallest * 0.3, - ), - tooltip: 'Change room icon', - onPressed: () { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: - const Text('Choose a room Icon'), - actions: const [], - content: SizedBox( - width: smallest * 0.3 * 3, - height: smallest * 0.3 * 3, - child: GridView.count( - crossAxisCount: 3, - children: RoomIcon.list() - .map((icon) { - return GridTile( - child: IconButton( - icon: SvgPicture - .asset( - icon.img, - width: smallest * - 0.3, - height: smallest * - 0.3, - ), - tooltip: icon.text, - onPressed: () { - setState(() { - _ctrIcon = icon; - }); - Navigator.of( - context) - .pop(); - })); - }).toList())), - )); - }, - ), - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: _ctrID, - keyboardType: TextInputType.emailAddress, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.fact_check), - labelText: 'Room ID', - hintText: 'Unique room id', - helperText: - 'the room id and server tag allow the room to be identified', - border: OutlineInputBorder(), - ), - ), - ), - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: _ctrName, - keyboardType: TextInputType.name, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.badge), - labelText: 'Room Name', - hintText: 'Give your room a name', - helperText: - 'Easily identify a room with a human readable name', - border: OutlineInputBorder(), - ), - ), - ), - Padding( - padding: const EdgeInsets.all(8), - child: TextField( - controller: _ctrDescription, - keyboardType: TextInputType.text, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.dns), - labelText: 'Room Description', - hintText: 'Briefly describe your Room', - helperText: - 'Make it easier for other to know what this room is used for', - border: OutlineInputBorder(), - ), - ), - ), - Text('Visibility', style: textTheme.labelLarge), - Text('Specify who has access to your room', - style: textTheme.bodySmall), - SegmentedButton( - showSelectedIcon: true, - multiSelectionEnabled: false, - emptySelectionAllowed: false, - segments: RoomVisibility.list().map((vis) { - return ButtonSegment( - value: vis, - label: Text(vis.text), - icon: Icon(vis.icon)); - }).toList(), - onSelectionChanged: ((vset) { - setState(() { - _ctrVis = vset.single; - }); - }), - selected: {_ctrVis}, - selectedIcon: Icon(_ctrVis.icon), - ), - ], - )))), + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 400), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + IconButton( + icon: SvgPicture.asset( + _ctrIcon.img, + width: smallest * 0.3, + height: smallest * 0.3, + ), + tooltip: 'Change room icon', + onPressed: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: + const Text('Choose a room Icon'), + actions: const [], + content: SizedBox( + width: smallest * 0.3 * 3, + height: smallest * 0.3 * 3, + child: GridView.count( + crossAxisCount: 3, + children: RoomIcon.list() + .map((icon) { + return GridTile( + child: IconButton( + icon: SvgPicture + .asset( + icon.img, + width: smallest * + 0.3, + height: smallest * + 0.3, + ), + tooltip: icon.text, + onPressed: () { + setState(() { + _ctrIcon = icon; + }); + Navigator.of( + context) + .pop(); + })); + }).toList())), + )); + }, + ), + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: _ctrID, + keyboardType: TextInputType.emailAddress, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.fact_check), + labelText: 'Room ID', + hintText: 'Unique room id', + helperText: + 'the room id and server tag allow the room to be identified', + border: OutlineInputBorder(), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: _ctrName, + keyboardType: TextInputType.name, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.badge), + labelText: 'Room Name', + hintText: 'Give your room a name', + helperText: + 'Easily identify a room with a human readable name', + border: OutlineInputBorder(), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8), + child: TextField( + controller: _ctrDescription, + keyboardType: TextInputType.text, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.dns), + labelText: 'Room Description', + hintText: 'Briefly describe your Room', + helperText: + 'Make it easier for other to know what this room is used for', + border: OutlineInputBorder(), + ), + ), + ), + Text('Visibility', style: textTheme.labelLarge), + Text('Specify who has access to your room', + style: textTheme.bodySmall), + SegmentedButton( + showSelectedIcon: true, + multiSelectionEnabled: false, + emptySelectionAllowed: false, + segments: RoomVisibility.list().map((vis) { + return ButtonSegment( + value: vis, + label: Text(vis.text), + icon: Icon(vis.icon)); + }).toList(), + onSelectionChanged: ((vset) { + setState(() { + _ctrVis = vset.single; + }); + }), + selected: {_ctrVis}, + selectedIcon: Icon(_ctrVis.icon), + ), + ], + ) + ) + ), floatingActionButton: FloatingActionButton.extended( onPressed: () async { final scaffMgr = ScaffoldMessenger.of(context);