mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 09:35:12 +00:00
fix: Do not allow empty search server
This commit is contained in:
parent
9238dbcd8d
commit
62122e5c79
3 changed files with 22 additions and 5 deletions
|
@ -1044,6 +1044,7 @@
|
||||||
"anyoneCanKnock": "Anyone can knock",
|
"anyoneCanKnock": "Anyone can knock",
|
||||||
"noOneCanJoin": "No one can join",
|
"noOneCanJoin": "No one can join",
|
||||||
"tryAgain": "Try again",
|
"tryAgain": "Try again",
|
||||||
|
"invalidServerName": "Invalid server name",
|
||||||
"invited": "Invited",
|
"invited": "Invited",
|
||||||
"@invited": {
|
"@invited": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
|
|
@ -181,6 +181,9 @@ class ChatListController extends State<ChatList>
|
||||||
initialText: searchServer,
|
initialText: searchServer,
|
||||||
keyboardType: TextInputType.url,
|
keyboardType: TextInputType.url,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
|
validator: (server) => server?.contains('.') == true
|
||||||
|
? null
|
||||||
|
: L10n.of(context)!.invalidServerName,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -244,6 +247,12 @@ class ChatListController extends State<ChatList>
|
||||||
_coolDown = Timer(const Duration(milliseconds: 500), _search);
|
_coolDown = Timer(const Duration(milliseconds: 500), _search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startSearch() {
|
||||||
|
setState(() {
|
||||||
|
isSearchMode = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void cancelSearch({bool unfocus = true}) {
|
void cancelSearch({bool unfocus = true}) {
|
||||||
setState(() {
|
setState(() {
|
||||||
searchController.clear();
|
searchController.clear();
|
||||||
|
|
|
@ -62,9 +62,12 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget {
|
||||||
onPressed: controller.cancelSearch,
|
onPressed: controller.cancelSearch,
|
||||||
color: Theme.of(context).colorScheme.onBackground,
|
color: Theme.of(context).colorScheme.onBackground,
|
||||||
)
|
)
|
||||||
: Icon(
|
: IconButton(
|
||||||
Icons.search_outlined,
|
onPressed: controller.startSearch,
|
||||||
color: Theme.of(context).colorScheme.onBackground,
|
icon: Icon(
|
||||||
|
Icons.search_outlined,
|
||||||
|
color: Theme.of(context).colorScheme.onBackground,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
suffixIcon: controller.isSearchMode
|
suffixIcon: controller.isSearchMode
|
||||||
? controller.isSearching
|
? controller.isSearching
|
||||||
|
@ -80,12 +83,16 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: TextButton(
|
: TextButton.icon(
|
||||||
onPressed: controller.setServer,
|
onPressed: controller.setServer,
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(99),
|
||||||
|
),
|
||||||
textStyle: const TextStyle(fontSize: 12),
|
textStyle: const TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
child: Text(
|
icon: const Icon(Icons.edit_outlined, size: 16),
|
||||||
|
label: Text(
|
||||||
controller.searchServer ??
|
controller.searchServer ??
|
||||||
Matrix.of(context)
|
Matrix.of(context)
|
||||||
.client
|
.client
|
||||||
|
|
Loading…
Reference in a new issue