1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Can update user public note

This commit is contained in:
Pierre HUBERT 2020-04-27 19:21:30 +02:00
parent 88ea7e2431
commit 75e15f9f83
4 changed files with 35 additions and 5 deletions

View File

@ -16,7 +16,7 @@ class GeneralSettings {
bool publicFriendsList;
final String virtualDirectory;
String personalWebsite;
final String publicNote;
String publicNote;
GeneralSettings({
@required this.email,

View File

@ -2,7 +2,10 @@ import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Ask the user to enter an URL
/// Dialog to use to ask the user to enter a value
///
/// @author Pierre Hubert
class SingleInputDialog extends StatefulWidget {
final String title;
final IconData icon;
@ -11,6 +14,8 @@ class SingleInputDialog extends StatefulWidget {
final bool Function(String) checkInput;
final String errorMessage;
final bool canBeEmpty;
final int maxLines;
final int maxLength;
const SingleInputDialog({
Key key,
@ -21,10 +26,13 @@ class SingleInputDialog extends StatefulWidget {
@required this.checkInput,
@required this.errorMessage,
this.canBeEmpty = false,
this.maxLines = 1,
this.maxLength,
}) : assert(title != null),
assert(label != null),
assert(checkInput != null),
assert(errorMessage != null),
assert(maxLines != null),
super(key: key);
@override
@ -51,6 +59,8 @@ class __InputURLDialogState extends State<SingleInputDialog> {
content: TextField(
controller: _controller,
onChanged: (s) => setState(() {}),
maxLines: widget.maxLines,
maxLength: widget.maxLength,
decoration: InputDecoration(
icon: widget.icon == null ? null : Icon(widget.icon),
alignLabelWithHint: true,

View File

@ -192,7 +192,7 @@ class __GeneralAccountSettingsBodyState
// Personal website
TextEditSettingsTile(
title: tr("Personal website URL"),
title: tr("Personal website URL (optional)"),
currValue: _settings.personalWebsite,
onChanged: (v) {
_settings.personalWebsite = v;
@ -200,7 +200,20 @@ class __GeneralAccountSettingsBodyState
},
checkInput: (s) => validateUrl(s),
allowEmptyValues: true,
)
),
// Public notes
TextEditSettingsTile(
title: tr("Public note (optional)"),
currValue: _settings.publicNote,
onChanged: (v) {
_settings.publicNote = v;
_updateSettings();
},
allowEmptyValues: true,
maxLength: 255,
maxLines: 3,
),
];
}

View File

@ -15,6 +15,8 @@ class TextEditSettingsTile extends SettingsTile {
final void Function(String) onChanged;
final bool Function(String) checkInput;
final bool allowEmptyValues;
final int maxLines;
final int maxLength;
bool get readOnly => onChanged == null;
@ -25,10 +27,13 @@ class TextEditSettingsTile extends SettingsTile {
@required this.onChanged,
this.checkInput = _defaultCheck,
this.allowEmptyValues = false,
this.maxLength,
this.maxLines = 1,
}) : assert(title != null),
assert(currValue != null),
assert(checkInput != null),
assert(allowEmptyValues != null);
assert(allowEmptyValues != null),
assert(maxLines != null);
@override
Widget build(BuildContext context) {
@ -50,6 +55,8 @@ class TextEditSettingsTile extends SettingsTile {
checkInput: checkInput,
errorMessage: tr("Invalid value!"),
canBeEmpty: allowEmptyValues,
maxLines: maxLines,
maxLength: maxLength,
),
);