Removed Flexible widget.

FIXES: Bug where signup, signin,
edit room and new room screen would fail to open,
because the Flexible Widget cannot be nested in a
Centered Widget.

NOTE: Turns out the widget was not neccessary at all
This commit is contained in:
Jakob Meier 2023-03-24 16:42:12 +01:00
parent fa734eca15
commit 672892e21b
No known key found for this signature in database
GPG key ID: 66BDC7E6A01A6152
3 changed files with 318 additions and 317 deletions

View file

@ -5,7 +5,6 @@ import 'package:outbag_app/tools/fetch_wrapper.dart';
import 'package:outbag_app/tools/snackbar.dart'; import 'package:outbag_app/tools/snackbar.dart';
import 'package:routemaster/routemaster.dart'; import 'package:routemaster/routemaster.dart';
import '../backend/resolve_url.dart'; import '../backend/resolve_url.dart';
import '../backend/errors.dart';
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
import 'dart:convert'; import 'dart:convert';
@ -70,105 +69,106 @@ class _AuthPageState extends State<AuthPage> {
), ),
), ),
body: Center( body: Center(
child: Flexible( child: ConstrainedBox(
child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 400),
constraints: const BoxConstraints(maxWidth: 400), child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: [
children: [ Padding(
Padding( padding: const EdgeInsets.all(8),
padding: const EdgeInsets.all(8), child: TextField(
child: TextField( controller: _ctrServer,
controller: _ctrServer, keyboardType: TextInputType.url,
keyboardType: TextInputType.url, decoration: const InputDecoration(
decoration: const InputDecoration( prefixIcon: Icon(Icons.dns),
prefixIcon: Icon(Icons.dns), labelText: 'Server',
labelText: 'Server', hintText: 'Your homeserver url',
hintText: 'Your homeserver url', helperText:
helperText: 'Your data will be stored on your homeserver',
'Your data will be stored on your homeserver', border: OutlineInputBorder(),
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, // ONLY SIGNUP OTA
decoration: const InputDecoration( ...((widget.mode == Mode.signupOTA)
prefixIcon: Icon(Icons.person), ? [
labelText: 'Username', Padding(
hintText: 'Your username', padding: const EdgeInsets.all(8),
helperText: child: TextField(
'your username and server tag allow others to identify you', controller: _ctrOTA,
border: OutlineInputBorder(), 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( floatingActionButton: FloatingActionButton.extended(
onPressed: () async { onPressed: () async {
setState(() { setState(() {

View file

@ -140,105 +140,106 @@ class _EditRoomPageState extends State<EditRoomPage> {
), ),
), ),
body: Center( body: Center(
child: Flexible( child: ConstrainedBox(
child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 400),
constraints: const BoxConstraints(maxWidth: 400), child: Column(
child: Column( mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, children: [
children: [ IconButton(
IconButton( icon: SvgPicture.asset(
icon: SvgPicture.asset( _ctrIcon.img,
_ctrIcon.img, width: smallest * 0.3,
width: smallest * 0.3, height: smallest * 0.3,
height: smallest * 0.3, ),
), tooltip: 'Change room icon',
tooltip: 'Change room icon', onPressed: () {
onPressed: () { showDialog(
showDialog( context: context,
context: context, builder: (ctx) => AlertDialog(
builder: (ctx) => AlertDialog( title:
title: const Text('Choose a room Icon'),
const Text('Choose a room Icon'), actions: const [],
actions: const [], content: SizedBox(
content: SizedBox( width: smallest * 0.3 * 3,
width: smallest * 0.3 * 3, height: smallest * 0.3 * 3,
height: smallest * 0.3 * 3, child: GridView.count(
child: GridView.count( crossAxisCount: 3,
crossAxisCount: 3, children: RoomIcon.list()
children: RoomIcon.list() .map((icon) {
.map((icon) { return GridTile(
return GridTile( child: IconButton(
child: IconButton( icon: SvgPicture
icon: SvgPicture .asset(
.asset( icon.img,
icon.img, width: smallest *
width: smallest * 0.3,
0.3, height: smallest *
height: smallest * 0.3,
0.3, ),
), tooltip: icon.text,
tooltip: icon.text, onPressed: () {
onPressed: () { setState(() {
setState(() { _ctrIcon = icon;
_ctrIcon = icon; });
}); Navigator.of(
Navigator.of( context)
context) .pop();
.pop(); }));
})); }).toList())),
}).toList())), ));
)); },
}, ),
), Padding(
Padding( padding: const EdgeInsets.all(8),
padding: const EdgeInsets.all(8), child: TextField(
child: TextField( enabled: false,
enabled: false, controller: _ctrID,
controller: _ctrID, keyboardType: TextInputType.emailAddress,
keyboardType: TextInputType.emailAddress, decoration: const InputDecoration(
decoration: const InputDecoration( prefixIcon: Icon(Icons.fact_check),
prefixIcon: Icon(Icons.fact_check), labelText: 'Room ID',
labelText: 'Room ID', hintText: 'Unique room id',
hintText: 'Unique room id', helperText:
helperText: 'the room id and server tag allow the room to be identified',
'the room id and server tag allow the room to be identified', border: OutlineInputBorder(),
border: OutlineInputBorder(), ),
), ),
), ),
), Padding(
Padding( padding: const EdgeInsets.all(8),
padding: const EdgeInsets.all(8), child: TextField(
child: TextField( controller: _ctrName,
controller: _ctrName, keyboardType: TextInputType.name,
keyboardType: TextInputType.name, decoration: const InputDecoration(
decoration: const InputDecoration( prefixIcon: Icon(Icons.badge),
prefixIcon: Icon(Icons.badge), labelText: 'Room Name',
labelText: 'Room Name', hintText: 'Give your room a name',
hintText: 'Give your room a name', helperText:
helperText: 'Easily identify a room with a human readable name',
'Easily identify a room with a human readable name', border: OutlineInputBorder(),
border: OutlineInputBorder(), ),
), ),
), ),
), Padding(
Padding( padding: const EdgeInsets.all(8),
padding: const EdgeInsets.all(8), child: TextField(
child: TextField( controller: _ctrDescription,
controller: _ctrDescription, keyboardType: TextInputType.text,
keyboardType: TextInputType.text, decoration: const InputDecoration(
decoration: const InputDecoration( prefixIcon: Icon(Icons.dns),
prefixIcon: Icon(Icons.dns), labelText: 'Room Description',
labelText: 'Room Description', hintText: 'Briefly describe your Room',
hintText: 'Briefly describe your Room', helperText:
helperText: 'Make it easier for other to know what this room is used for',
'Make it easier for other to know what this room is used for', border: OutlineInputBorder(),
border: OutlineInputBorder(), ),
), ),
), ),
), ],
], )
)))), )
),
floatingActionButton: FloatingActionButton.extended( floatingActionButton: FloatingActionButton.extended(
onPressed: () async { onPressed: () async {
final scaffMgr = ScaffoldMessenger.of(context); final scaffMgr = ScaffoldMessenger.of(context);

View file

@ -1,6 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.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/request.dart';
import 'package:outbag_app/backend/room.dart'; import 'package:outbag_app/backend/room.dart';
import 'package:outbag_app/backend/user.dart'; import 'package:outbag_app/backend/user.dart';
@ -58,125 +57,126 @@ class _NewRoomPageState extends State {
), ),
), ),
body: Center( body: Center(
child: Flexible( child: ConstrainedBox(
child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 400),
constraints: const BoxConstraints(maxWidth: 400), child: Column(
child: Column( mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, children: [
children: [ IconButton(
IconButton( icon: SvgPicture.asset(
icon: SvgPicture.asset( _ctrIcon.img,
_ctrIcon.img, width: smallest * 0.3,
width: smallest * 0.3, height: smallest * 0.3,
height: smallest * 0.3, ),
), tooltip: 'Change room icon',
tooltip: 'Change room icon', onPressed: () {
onPressed: () { showDialog(
showDialog( context: context,
context: context, builder: (ctx) => AlertDialog(
builder: (ctx) => AlertDialog( title:
title: const Text('Choose a room Icon'),
const Text('Choose a room Icon'), actions: const [],
actions: const [], content: SizedBox(
content: SizedBox( width: smallest * 0.3 * 3,
width: smallest * 0.3 * 3, height: smallest * 0.3 * 3,
height: smallest * 0.3 * 3, child: GridView.count(
child: GridView.count( crossAxisCount: 3,
crossAxisCount: 3, children: RoomIcon.list()
children: RoomIcon.list() .map((icon) {
.map((icon) { return GridTile(
return GridTile( child: IconButton(
child: IconButton( icon: SvgPicture
icon: SvgPicture .asset(
.asset( icon.img,
icon.img, width: smallest *
width: smallest * 0.3,
0.3, height: smallest *
height: smallest * 0.3,
0.3, ),
), tooltip: icon.text,
tooltip: icon.text, onPressed: () {
onPressed: () { setState(() {
setState(() { _ctrIcon = icon;
_ctrIcon = icon; });
}); Navigator.of(
Navigator.of( context)
context) .pop();
.pop(); }));
})); }).toList())),
}).toList())), ));
)); },
}, ),
), Padding(
Padding( padding: const EdgeInsets.all(8),
padding: const EdgeInsets.all(8), child: TextField(
child: TextField( controller: _ctrID,
controller: _ctrID, keyboardType: TextInputType.emailAddress,
keyboardType: TextInputType.emailAddress, decoration: const InputDecoration(
decoration: const InputDecoration( prefixIcon: Icon(Icons.fact_check),
prefixIcon: Icon(Icons.fact_check), labelText: 'Room ID',
labelText: 'Room ID', hintText: 'Unique room id',
hintText: 'Unique room id', helperText:
helperText: 'the room id and server tag allow the room to be identified',
'the room id and server tag allow the room to be identified', border: OutlineInputBorder(),
border: OutlineInputBorder(), ),
), ),
), ),
), Padding(
Padding( padding: const EdgeInsets.all(8),
padding: const EdgeInsets.all(8), child: TextField(
child: TextField( controller: _ctrName,
controller: _ctrName, keyboardType: TextInputType.name,
keyboardType: TextInputType.name, decoration: const InputDecoration(
decoration: const InputDecoration( prefixIcon: Icon(Icons.badge),
prefixIcon: Icon(Icons.badge), labelText: 'Room Name',
labelText: 'Room Name', hintText: 'Give your room a name',
hintText: 'Give your room a name', helperText:
helperText: 'Easily identify a room with a human readable name',
'Easily identify a room with a human readable name', border: OutlineInputBorder(),
border: OutlineInputBorder(), ),
), ),
), ),
), Padding(
Padding( padding: const EdgeInsets.all(8),
padding: const EdgeInsets.all(8), child: TextField(
child: TextField( controller: _ctrDescription,
controller: _ctrDescription, keyboardType: TextInputType.text,
keyboardType: TextInputType.text, decoration: const InputDecoration(
decoration: const InputDecoration( prefixIcon: Icon(Icons.dns),
prefixIcon: Icon(Icons.dns), labelText: 'Room Description',
labelText: 'Room Description', hintText: 'Briefly describe your Room',
hintText: 'Briefly describe your Room', helperText:
helperText: 'Make it easier for other to know what this room is used for',
'Make it easier for other to know what this room is used for', border: OutlineInputBorder(),
border: OutlineInputBorder(), ),
), ),
), ),
), Text('Visibility', style: textTheme.labelLarge),
Text('Visibility', style: textTheme.labelLarge), Text('Specify who has access to your room',
Text('Specify who has access to your room', style: textTheme.bodySmall),
style: textTheme.bodySmall), SegmentedButton<RoomVisibility>(
SegmentedButton<RoomVisibility>( showSelectedIcon: true,
showSelectedIcon: true, multiSelectionEnabled: false,
multiSelectionEnabled: false, emptySelectionAllowed: false,
emptySelectionAllowed: false, segments: RoomVisibility.list().map((vis) {
segments: RoomVisibility.list().map((vis) { return ButtonSegment<RoomVisibility>(
return ButtonSegment<RoomVisibility>( value: vis,
value: vis, label: Text(vis.text),
label: Text(vis.text), icon: Icon(vis.icon));
icon: Icon(vis.icon)); }).toList(),
}).toList(), onSelectionChanged: ((vset) {
onSelectionChanged: ((vset) { setState(() {
setState(() { _ctrVis = vset.single;
_ctrVis = vset.single; });
}); }),
}), selected: {_ctrVis},
selected: {_ctrVis}, selectedIcon: Icon(_ctrVis.icon),
selectedIcon: Icon(_ctrVis.icon), ),
), ],
], )
)))), )
),
floatingActionButton: FloatingActionButton.extended( floatingActionButton: FloatingActionButton.extended(
onPressed: () async { onPressed: () async {
final scaffMgr = ScaffoldMessenger.of(context); final scaffMgr = ScaffoldMessenger.of(context);