Autofocus key fields, fix padding/margins on group settings

This commit is contained in:
Sarah Jamie Lewis 2021-05-26 10:06:29 -07:00
parent 68d7020820
commit 26c76a4b34
4 changed files with 42 additions and 29 deletions

View File

@ -60,9 +60,32 @@ class _GroupSettingsViewState extends State<GroupSettingsView> {
minHeight: viewportConstraints.maxHeight,
),
child: Container(
margin: EdgeInsets.all(30),
padding: EdgeInsets.all(20),
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(2),
child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch, children: [
// Nickname Save Button
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
SizedBox(
height: 20,
),
CwtchLabel(label: AppLocalizations.of(context)!.displayNameLabel),
SizedBox(
height: 20,
),
CwtchButtonTextField(
controller: ctrlrNick,
readonly: false,
onPressed: () {
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
var handle = Provider.of<ContactInfoState>(context, listen: false).onion;
Provider.of<ContactInfoState>(context, listen: false).nickname = ctrlrNick.text;
Provider.of<FlwtchState>(context, listen: false).cwtch.SetGroupAttribute(profileOnion, handle, "local.name", ctrlrNick.text);
},
icon: Icon(Icons.save),
tooltip: AppLocalizations.of(context)!.saveBtn,
)
]),
// Address Copy Button
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
SizedBox(
@ -92,28 +115,7 @@ class _GroupSettingsViewState extends State<GroupSettingsView> {
labelText: '',
)
]),
// Nickname Save Button
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
SizedBox(
height: 20,
),
CwtchLabel(label: AppLocalizations.of(context)!.displayNameLabel),
SizedBox(
height: 20,
),
CwtchButtonTextField(
controller: ctrlrNick,
readonly: false,
onPressed: () {
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
var handle = Provider.of<ContactInfoState>(context, listen: false).onion;
Provider.of<ContactInfoState>(context, listen: false).nickname = ctrlrNick.text;
Provider.of<FlwtchState>(context, listen: false).cwtch.SetGroupAttribute(profileOnion, handle, "local.name", ctrlrNick.text);
},
icon: Icon(Icons.save),
tooltip: AppLocalizations.of(context)!.saveBtn,
)
]),
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
SizedBox(
height: 20,

View File

@ -126,6 +126,7 @@ class _MessageViewState extends State<MessageView> {
child: TextFormField(
key: Key('txtCompose'),
controller: ctrlrCompose,
autofocus: true,
focusNode: focusNode,
textInputAction: TextInputAction.send,
onFieldSubmitted: _sendMessage,

View File

@ -130,7 +130,9 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
height: 20,
),
CwtchPasswordField(
autofocus: true,
controller: ctrlrPassword,
action: unlock,
validator: (value) {},
),
SizedBox(
@ -142,9 +144,7 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
child: ElevatedButton(
child: Text(AppLocalizations.of(context)!.unlock, semanticsLabel: AppLocalizations.of(context)!.unlock),
onPressed: () {
Provider.of<FlwtchState>(context, listen: false).cwtch.LoadProfiles(ctrlrPassword.value.text);
ctrlrPassword.text = "";
Navigator.pop(context);
unlock(ctrlrPassword.value.text);
},
)),
Spacer()
@ -155,6 +155,12 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
});
}
void unlock(String password) {
Provider.of<FlwtchState>(context, listen: false).cwtch.LoadProfiles(password);
ctrlrPassword.text = "";
Navigator.pop(context);
}
Widget _buildProfileManager() {
return Consumer<ProfileListState>(
builder: (context, pls, child) {

View File

@ -5,9 +5,11 @@ import '../settings.dart';
// Provides a styled Password Input Field for use in Form Widgets.
// Callers must provide a text controller, label helper text and a validator.
class CwtchPasswordField extends StatefulWidget {
CwtchPasswordField({required this.controller, required this.validator});
CwtchPasswordField({required this.controller, required this.validator, this.action, this.autofocus = true});
final TextEditingController controller;
final FormFieldValidator validator;
final Function(String)? action;
final bool autofocus;
@override
_CwtchTextFieldState createState() => _CwtchTextFieldState();
@ -26,11 +28,13 @@ class _CwtchTextFieldState extends State<CwtchPasswordField> {
return Consumer<Settings>(builder: (context, theme, child) {
return TextFormField(
autofocus: widget.autofocus,
controller: widget.controller,
validator: widget.validator,
obscureText: obscureText,
onFieldSubmitted: widget.action,
textInputAction: TextInputAction.unspecified,
enableSuggestions: false,
textInputAction: TextInputAction.continueAction,
autocorrect: false,
decoration: InputDecoration(
suffixIcon: IconButton(