1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-10-23 06:53:23 +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; bool publicFriendsList;
final String virtualDirectory; final String virtualDirectory;
String personalWebsite; String personalWebsite;
final String publicNote; String publicNote;
GeneralSettings({ GeneralSettings({
@required this.email, @required this.email,

View File

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

View File

@ -192,7 +192,7 @@ class __GeneralAccountSettingsBodyState
// Personal website // Personal website
TextEditSettingsTile( TextEditSettingsTile(
title: tr("Personal website URL"), title: tr("Personal website URL (optional)"),
currValue: _settings.personalWebsite, currValue: _settings.personalWebsite,
onChanged: (v) { onChanged: (v) {
_settings.personalWebsite = v; _settings.personalWebsite = v;
@ -200,7 +200,20 @@ class __GeneralAccountSettingsBodyState
}, },
checkInput: (s) => validateUrl(s), checkInput: (s) => validateUrl(s),
allowEmptyValues: true, 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 void Function(String) onChanged;
final bool Function(String) checkInput; final bool Function(String) checkInput;
final bool allowEmptyValues; final bool allowEmptyValues;
final int maxLines;
final int maxLength;
bool get readOnly => onChanged == null; bool get readOnly => onChanged == null;
@ -25,10 +27,13 @@ class TextEditSettingsTile extends SettingsTile {
@required this.onChanged, @required this.onChanged,
this.checkInput = _defaultCheck, this.checkInput = _defaultCheck,
this.allowEmptyValues = false, this.allowEmptyValues = false,
this.maxLength,
this.maxLines = 1,
}) : assert(title != null), }) : assert(title != null),
assert(currValue != null), assert(currValue != null),
assert(checkInput != null), assert(checkInput != null),
assert(allowEmptyValues != null); assert(allowEmptyValues != null),
assert(maxLines != null);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -50,6 +55,8 @@ class TextEditSettingsTile extends SettingsTile {
checkInput: checkInput, checkInput: checkInput,
errorMessage: tr("Invalid value!"), errorMessage: tr("Invalid value!"),
canBeEmpty: allowEmptyValues, canBeEmpty: allowEmptyValues,
maxLines: maxLines,
maxLength: maxLength,
), ),
); );