mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-02-17 14:30:40 +01:00
feat: Better invite search bar
This commit is contained in:
parent
f0d1f5aed2
commit
3c4a29b517
@ -1,16 +1,21 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
||||||
|
|
||||||
class DefaultAppBarSearchField extends StatefulWidget {
|
class DefaultAppBarSearchField extends StatefulWidget {
|
||||||
final TextEditingController searchController;
|
final TextEditingController searchController;
|
||||||
final void Function(String) onChanged;
|
final void Function(String) onChanged;
|
||||||
final Widget suffix;
|
final Widget suffix;
|
||||||
|
final bool autofocus;
|
||||||
|
final String prefixText;
|
||||||
|
final String hintText;
|
||||||
|
|
||||||
const DefaultAppBarSearchField({
|
const DefaultAppBarSearchField({
|
||||||
Key key,
|
Key key,
|
||||||
this.searchController,
|
this.searchController,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.suffix,
|
this.suffix,
|
||||||
|
this.autofocus = false,
|
||||||
|
this.prefixText,
|
||||||
|
this.hintText,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -59,11 +64,13 @@ class _DefaultAppBarSearchFieldState extends State<DefaultAppBarSearchField> {
|
|||||||
color: Theme.of(context).secondaryHeaderColor,
|
color: Theme.of(context).secondaryHeaderColor,
|
||||||
borderRadius: BorderRadius.circular(32),
|
borderRadius: BorderRadius.circular(32),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
|
autofocus: widget.autofocus,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
controller: _searchController,
|
controller: _searchController,
|
||||||
onChanged: widget.onChanged,
|
onChanged: widget.onChanged,
|
||||||
focusNode: _focusNode,
|
focusNode: _focusNode,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
prefixText: widget.prefixText,
|
||||||
contentPadding: EdgeInsets.only(
|
contentPadding: EdgeInsets.only(
|
||||||
top: 8,
|
top: 8,
|
||||||
bottom: 8,
|
bottom: 8,
|
||||||
@ -72,7 +79,7 @@ class _DefaultAppBarSearchFieldState extends State<DefaultAppBarSearchField> {
|
|||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(32),
|
borderRadius: BorderRadius.circular(32),
|
||||||
),
|
),
|
||||||
hintText: L10n.of(context).searchForAChat,
|
hintText: widget.hintText,
|
||||||
suffixIcon: _focusNode.hasFocus ||
|
suffixIcon: _focusNode.hasFocus ||
|
||||||
(widget.suffix == null &&
|
(widget.suffix == null &&
|
||||||
(_searchController.text?.isNotEmpty ?? false))
|
(_searchController.text?.isNotEmpty ?? false))
|
||||||
|
@ -272,6 +272,7 @@ class _ChatListState extends State<ChatList> {
|
|||||||
? Text(_selectedRoomIds.length.toString())
|
? Text(_selectedRoomIds.length.toString())
|
||||||
: DefaultAppBarSearchField(
|
: DefaultAppBarSearchField(
|
||||||
searchController: searchController,
|
searchController: searchController,
|
||||||
|
hintText: L10n.of(context).searchForAChat,
|
||||||
onChanged: (_) => setState(() => null),
|
onChanged: (_) => setState(() => null),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -146,6 +146,7 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
|||||||
elevation: _scrolledToTop ? 0 : null,
|
elevation: _scrolledToTop ? 0 : null,
|
||||||
title: DefaultAppBarSearchField(
|
title: DefaultAppBarSearchField(
|
||||||
onChanged: (text) => _search(context, text),
|
onChanged: (text) => _search(context, text),
|
||||||
|
hintText: L10n.of(context).searchForAChat,
|
||||||
suffix: IconButton(
|
suffix: IconButton(
|
||||||
icon: Icon(Icons.edit_outlined),
|
icon: Icon(Icons.edit_outlined),
|
||||||
onPressed: () => _setServer(context),
|
onPressed: () => _setServer(context),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:fluffychat/components/default_app_bar_search_field.dart';
|
||||||
import 'package:flushbar/flushbar_helper.dart';
|
import 'package:flushbar/flushbar_helper.dart';
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:famedlysdk/matrix_api.dart';
|
import 'package:famedlysdk/matrix_api.dart';
|
||||||
@ -120,35 +121,11 @@ class _InvitationSelectionState extends State<InvitationSelection> {
|
|||||||
firstScaffold: ChatList(activeChat: widget.room.id),
|
firstScaffold: ChatList(activeChat: widget.room.id),
|
||||||
secondScaffold: Scaffold(
|
secondScaffold: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(L10n.of(context).inviteContact),
|
titleSpacing: 0,
|
||||||
bottom: PreferredSize(
|
title: DefaultAppBarSearchField(
|
||||||
preferredSize: Size.fromHeight(92),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: TextField(
|
|
||||||
controller: controller,
|
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
autocorrect: false,
|
hintText: L10n.of(context).inviteContactToGroup(groupName),
|
||||||
textInputAction: TextInputAction.search,
|
onChanged: (String text) => searchUserWithCoolDown(context, text),
|
||||||
onChanged: (String text) =>
|
|
||||||
searchUserWithCoolDown(context, text),
|
|
||||||
onSubmitted: (String text) => searchUser(context, text),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
prefixText: '@',
|
|
||||||
hintText: L10n.of(context).username,
|
|
||||||
labelText: L10n.of(context).inviteContactToGroup(groupName),
|
|
||||||
suffixIcon: loading
|
|
||||||
? Container(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
width: 12,
|
|
||||||
height: 12,
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Icon(Icons.search_outlined),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: foundProfiles.isNotEmpty
|
body: foundProfiles.isNotEmpty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user