change: Minor design changes
This commit is contained in:
parent
cdecceb30d
commit
c08c680f05
7 changed files with 197 additions and 86 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/connection_status_header.dart';
|
||||
|
|
@ -13,11 +15,13 @@ enum SelectMode { normal, select }
|
|||
class ChatList extends StatefulWidget {
|
||||
final String activeChat;
|
||||
final void Function(AppBar appBar) onCustomAppBar;
|
||||
final Stream onAppBarButtonTap;
|
||||
|
||||
const ChatList({
|
||||
Key key,
|
||||
this.activeChat,
|
||||
this.onCustomAppBar,
|
||||
this.onAppBarButtonTap,
|
||||
}) : super(key: key);
|
||||
@override
|
||||
_ChatListState createState() => _ChatListState();
|
||||
|
|
@ -28,6 +32,32 @@ class _ChatListState extends State<ChatList> {
|
|||
final TextEditingController searchController = TextEditingController();
|
||||
final _selectedRoomIds = <String>{};
|
||||
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
StreamSubscription _onAppBarButtonTapSub;
|
||||
final GlobalKey<DefaultAppBarSearchFieldState> _searchField = GlobalKey();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_onAppBarButtonTapSub =
|
||||
widget.onAppBarButtonTap.where((i) => i == 1).listen((_) async {
|
||||
await _scrollController.animateTo(
|
||||
_scrollController.position.minScrollExtent,
|
||||
duration: Duration(milliseconds: 200),
|
||||
curve: Curves.ease,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => _searchField.currentState.requestFocus(),
|
||||
);
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_onAppBarButtonTapSub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _toggleSelection(String roomId) {
|
||||
setState(() => _selectedRoomIds.contains(roomId)
|
||||
? _selectedRoomIds.remove(roomId)
|
||||
|
|
@ -198,11 +228,13 @@ class _ChatListState extends State<ChatList> {
|
|||
}
|
||||
final totalCount = rooms.length;
|
||||
return ListView.builder(
|
||||
controller: _scrollController,
|
||||
itemCount: totalCount + 1,
|
||||
itemBuilder: (BuildContext context, int i) => i == 0
|
||||
? Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: DefaultAppBarSearchField(
|
||||
key: _searchField,
|
||||
hintText: L10n.of(context).search,
|
||||
prefixIcon: Icon(Icons.search_outlined),
|
||||
searchController: searchController,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/avatar.dart';
|
||||
import 'package:fluffychat/components/default_app_bar_search_field.dart';
|
||||
|
|
@ -8,65 +10,98 @@ import '../../utils/client_presence_extension.dart';
|
|||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class ContactList extends StatefulWidget {
|
||||
final Stream onAppBarButtonTap;
|
||||
|
||||
const ContactList({Key key, this.onAppBarButtonTap}) : super(key: key);
|
||||
@override
|
||||
_ContactListState createState() => _ContactListState();
|
||||
}
|
||||
|
||||
class _ContactListState extends State<ContactList> {
|
||||
String _searchQuery = '';
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
StreamSubscription _onAppBarButtonTapSub;
|
||||
final GlobalKey<DefaultAppBarSearchFieldState> _searchField = GlobalKey();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_onAppBarButtonTapSub =
|
||||
widget.onAppBarButtonTap.where((i) => i == 0).listen((_) async {
|
||||
await _scrollController.animateTo(
|
||||
_scrollController.position.minScrollExtent,
|
||||
duration: Duration(milliseconds: 200),
|
||||
curve: Curves.ease,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => _searchField.currentState.requestFocus(),
|
||||
);
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_onAppBarButtonTapSub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: DefaultAppBarSearchField(
|
||||
hintText: L10n.of(context).search,
|
||||
prefixIcon: Icon(Icons.search_outlined),
|
||||
onChanged: (t) => setState(() => _searchQuery = t),
|
||||
padding: EdgeInsets.zero,
|
||||
return ListView(
|
||||
controller: _scrollController,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: DefaultAppBarSearchField(
|
||||
key: _searchField,
|
||||
hintText: L10n.of(context).search,
|
||||
prefixIcon: Icon(Icons.search_outlined),
|
||||
onChanged: (t) => setState(() => _searchQuery = t),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.add_outlined),
|
||||
radius: Avatar.defaultSize / 2,
|
||||
ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.add_outlined),
|
||||
radius: Avatar.defaultSize / 2,
|
||||
),
|
||||
title: Text(L10n.of(context).addNewContact),
|
||||
onTap: () =>
|
||||
AdaptivePageLayout.of(context).pushNamed('/newprivatechat'),
|
||||
),
|
||||
title: Text('Add new contact'),
|
||||
onTap: () =>
|
||||
AdaptivePageLayout.of(context).pushNamed('/newprivatechat'),
|
||||
),
|
||||
Divider(height: 1),
|
||||
StreamBuilder<Object>(
|
||||
stream: Matrix.of(context).client.onSync.stream,
|
||||
builder: (context, snapshot) {
|
||||
final contactList = Matrix.of(context)
|
||||
.client
|
||||
.contactList
|
||||
.where((p) => p.senderId
|
||||
.toLowerCase()
|
||||
.contains(_searchQuery.toLowerCase()))
|
||||
.toList();
|
||||
if (contactList.isEmpty) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'No contacts found...',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Divider(height: 1),
|
||||
StreamBuilder<Object>(
|
||||
stream: Matrix.of(context).client.onSync.stream,
|
||||
builder: (context, snapshot) {
|
||||
final contactList = Matrix.of(context)
|
||||
.client
|
||||
.contactList
|
||||
.where((p) => p.senderId
|
||||
.toLowerCase()
|
||||
.contains(_searchQuery.toLowerCase()))
|
||||
.toList();
|
||||
if (contactList.isEmpty) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'No contacts found...',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.only(bottom: 24),
|
||||
itemCount: contactList.length,
|
||||
itemBuilder: (context, i) =>
|
||||
ContactListTile(contact: contactList[i]),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.only(bottom: 24),
|
||||
itemCount: contactList.length,
|
||||
itemBuilder: (context, i) =>
|
||||
ContactListTile(contact: contactList[i]),
|
||||
);
|
||||
}),
|
||||
]);
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,11 +14,13 @@ class Discover extends StatefulWidget {
|
|||
final String alias;
|
||||
|
||||
final String server;
|
||||
final Stream onAppBarButtonTap;
|
||||
|
||||
const Discover({
|
||||
Key key,
|
||||
this.alias,
|
||||
this.server,
|
||||
this.onAppBarButtonTap,
|
||||
}) : super(key: key);
|
||||
@override
|
||||
_DiscoverState createState() => _DiscoverState();
|
||||
|
|
@ -29,6 +31,16 @@ class _DiscoverState extends State<Discover> {
|
|||
Timer _coolDown;
|
||||
String _genericSearchTerm;
|
||||
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
StreamSubscription _onAppBarButtonTapSub;
|
||||
final GlobalKey<DefaultAppBarSearchFieldState> _searchField = GlobalKey();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_onAppBarButtonTapSub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _search(BuildContext context, String query) async {
|
||||
_coolDown?.cancel();
|
||||
_coolDown = Timer(
|
||||
|
|
@ -86,6 +98,17 @@ class _DiscoverState extends State<Discover> {
|
|||
@override
|
||||
void initState() {
|
||||
_genericSearchTerm = widget.alias;
|
||||
_onAppBarButtonTapSub =
|
||||
widget.onAppBarButtonTap.where((i) => i == 2).listen((_) async {
|
||||
await _scrollController.animateTo(
|
||||
_scrollController.position.minScrollExtent,
|
||||
duration: Duration(milliseconds: 200),
|
||||
curve: Curves.ease,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => _searchField.currentState.requestFocus(),
|
||||
);
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
|
@ -121,10 +144,12 @@ class _DiscoverState extends State<Discover> {
|
|||
return res;
|
||||
});
|
||||
return ListView(
|
||||
controller: _scrollController,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: DefaultAppBarSearchField(
|
||||
key: _searchField,
|
||||
hintText: L10n.of(context).search,
|
||||
prefixIcon: Icon(Icons.search_outlined),
|
||||
onChanged: (t) => _search(context, t),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/dialogs/bootstrap_dialog.dart';
|
||||
|
|
@ -26,6 +28,9 @@ import '../../app_config.dart';
|
|||
import '../../config/setting_keys.dart';
|
||||
|
||||
class Settings extends StatefulWidget {
|
||||
final Stream onAppBarButtonTap;
|
||||
|
||||
const Settings({Key key, this.onAppBarButtonTap}) : super(key: key);
|
||||
@override
|
||||
_SettingsState createState() => _SettingsState();
|
||||
}
|
||||
|
|
@ -37,6 +42,21 @@ class _SettingsState extends State<Settings> {
|
|||
bool crossSigningCached;
|
||||
Future<bool> megolmBackupCachedFuture;
|
||||
bool megolmBackupCached;
|
||||
StreamSubscription _onAppBarButtonTapSub;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_onAppBarButtonTapSub = widget.onAppBarButtonTap
|
||||
.where((i) => i == 3)
|
||||
.listen((_) => logoutAction(context));
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_onAppBarButtonTapSub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void logoutAction(BuildContext context) async {
|
||||
if (await showOkCancelAlertDialog(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue