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",
|
||||
"noOneCanJoin": "No one can join",
|
||||
"tryAgain": "Try again",
|
||||
"invalidServerName": "Invalid server name",
|
||||
"invited": "Invited",
|
||||
"@invited": {
|
||||
"type": "text",
|
||||
|
|
|
@ -181,6 +181,9 @@ class ChatListController extends State<ChatList>
|
|||
initialText: searchServer,
|
||||
keyboardType: TextInputType.url,
|
||||
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);
|
||||
}
|
||||
|
||||
void startSearch() {
|
||||
setState(() {
|
||||
isSearchMode = true;
|
||||
});
|
||||
}
|
||||
|
||||
void cancelSearch({bool unfocus = true}) {
|
||||
setState(() {
|
||||
searchController.clear();
|
||||
|
|
|
@ -62,9 +62,12 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||
onPressed: controller.cancelSearch,
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
)
|
||||
: Icon(
|
||||
Icons.search_outlined,
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
: IconButton(
|
||||
onPressed: controller.startSearch,
|
||||
icon: Icon(
|
||||
Icons.search_outlined,
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
),
|
||||
),
|
||||
suffixIcon: controller.isSearchMode
|
||||
? controller.isSearching
|
||||
|
@ -80,12 +83,16 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||
),
|
||||
),
|
||||
)
|
||||
: TextButton(
|
||||
: TextButton.icon(
|
||||
onPressed: controller.setServer,
|
||||
style: TextButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
),
|
||||
textStyle: const TextStyle(fontSize: 12),
|
||||
),
|
||||
child: Text(
|
||||
icon: const Icon(Icons.edit_outlined, size: 16),
|
||||
label: Text(
|
||||
controller.searchServer ??
|
||||
Matrix.of(context)
|
||||
.client
|
||||
|
|
Loading…
Reference in a new issue