chore: Follow up homeserver picker input

This commit is contained in:
Krille Fear 2022-12-25 10:50:41 +01:00
parent 51a5e7f9cc
commit 4680a1c507
3 changed files with 524 additions and 506 deletions

View File

@ -13,7 +13,6 @@ import 'package:fluffychat/pages/chat_list/stories_header.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/profile_bottom_sheet.dart';
import 'package:fluffychat/widgets/public_room_bottom_sheet.dart';
import '../../utils/stream_extension.dart';
import '../../widgets/connection_status_header.dart';
import '../../widgets/matrix.dart';
@ -42,14 +41,7 @@ class ChatListViewBody extends StatelessWidget {
child: child,
);
},
child: StreamBuilder(
key: ValueKey(client.userID.toString() +
controller.activeFilter.toString() +
controller.activeSpaceId.toString()),
stream: client.onSync.stream
.where((s) => s.hasRoomUpdate)
.rateLimit(const Duration(seconds: 1)),
builder: (context, _) {
child: Builder(builder: (context) {
if (controller.activeFilter == ActiveFilter.spaces &&
!controller.isSearchMode) {
return SpaceView(
@ -95,8 +87,8 @@ class ChatListViewBody extends StatelessWidget {
onPressed: () => showModalBottomSheet(
context: context,
builder: (c) => PublicRoomBottomSheet(
roomAlias: roomSearchResult
.chunk[i].canonicalAlias ??
roomAlias:
roomSearchResult.chunk[i].canonicalAlias ??
roomSearchResult.chunk[i].roomId,
outerContext: context,
chunk: roomSearchResult.chunk[i],
@ -120,10 +112,8 @@ class ChatListViewBody extends StatelessWidget {
scrollDirection: Axis.horizontal,
itemCount: userSearchResult.results.length,
itemBuilder: (context, i) => _SearchItem(
title:
userSearchResult.results[i].displayName ??
userSearchResult
.results[i].userId.localpart ??
title: userSearchResult.results[i].displayName ??
userSearchResult.results[i].userId.localpart ??
L10n.of(context)!.unknownDevice,
avatar: userSearchResult.results[i].avatarUrl,
onPressed: () => showModalBottomSheet(
@ -159,10 +149,8 @@ class ChatListViewBody extends StatelessWidget {
child: ListTile(
leading: const Icon(Icons.vpn_key),
title: Text(L10n.of(context)!.dehydrateTor),
subtitle:
Text(L10n.of(context)!.dehydrateTorLong),
trailing:
const Icon(Icons.chevron_right_outlined),
subtitle: Text(L10n.of(context)!.dehydrateTorLong),
trailing: const Icon(Icons.chevron_right_outlined),
onTap: controller.dehydrate,
),
),
@ -184,9 +172,7 @@ class ChatListViewBody extends StatelessWidget {
),
Divider(
height: 1,
color: Theme.of(context)
.colorScheme
.onBackground,
color: Theme.of(context).colorScheme.onBackground,
),
const SizedBox(height: 32),
FloatingActionButton.extended(
@ -206,8 +192,10 @@ class ChatListViewBody extends StatelessWidget {
);
}
i--;
if (!rooms[i].displayname.toLowerCase().contains(
controller.searchController.text.toLowerCase())) {
if (!rooms[i]
.displayname
.toLowerCase()
.contains(controller.searchController.text.toLowerCase())) {
return Container();
}
return ChatListItem(

View File

@ -4,11 +4,13 @@ import 'package:flutter/services.dart';
import 'package:badges/badges.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
import 'package:matrix/matrix.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/utils/stream_extension.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/unread_rooms_badge.dart';
import '../../widgets/matrix.dart';
@ -103,12 +105,21 @@ class ChatListView extends StatelessWidget {
return;
}
},
child: Row(
child: StreamBuilder<Object>(
key: ValueKey(client.userID.toString() +
controller.activeFilter.toString() +
controller.activeSpaceId.toString()),
stream: client.onSync.stream
.where((s) => s.hasRoomUpdate)
.rateLimit(const Duration(seconds: 1)),
builder: (context, snapshot) {
return Row(
children: [
if (FluffyThemes.isColumnMode(context) &&
FluffyThemes.getDisplayNavigationRail(context)) ...[
Builder(builder: (context) {
final allSpaces = client.rooms.where((room) => room.isSpace);
final allSpaces =
client.rooms.where((room) => room.isSpace);
final rootSpaces = allSpaces
.where(
(space) => !allSpaces.any(
@ -126,7 +137,8 @@ class ChatListView extends StatelessWidget {
itemCount: rootSpaces.length + destinations.length,
itemBuilder: (context, i) {
if (i < destinations.length) {
final isSelected = i == controller.selectedIndex;
final isSelected =
i == controller.selectedIndex;
return Container(
height: 64,
width: 64,
@ -135,12 +147,15 @@ class ChatListView extends StatelessWidget {
bottom: i == (destinations.length - 1)
? BorderSide(
width: 1,
color: Theme.of(context).dividerColor,
color: Theme.of(context)
.dividerColor,
)
: BorderSide.none,
left: BorderSide(
color: isSelected
? Theme.of(context).colorScheme.primary
? Theme.of(context)
.colorScheme
.primary
: Colors.transparent,
width: 4,
),
@ -153,11 +168,15 @@ class ChatListView extends StatelessWidget {
alignment: Alignment.center,
child: IconButton(
color: isSelected
? Theme.of(context).colorScheme.secondary
? Theme.of(context)
.colorScheme
.secondary
: null,
icon: CircleAvatar(
backgroundColor: isSelected
? Theme.of(context).colorScheme.secondary
? Theme.of(context)
.colorScheme
.secondary
: Theme.of(context)
.colorScheme
.background,
@ -179,8 +198,8 @@ class ChatListView extends StatelessWidget {
);
}
i -= destinations.length;
final isSelected =
controller.activeFilter == ActiveFilter.spaces &&
final isSelected = controller.activeFilter ==
ActiveFilter.spaces &&
rootSpaces[i].id == controller.activeSpaceId;
return Container(
height: 64,
@ -189,7 +208,9 @@ class ChatListView extends StatelessWidget {
border: Border(
left: BorderSide(
color: isSelected
? Theme.of(context).colorScheme.secondary
? Theme.of(context)
.colorScheme
.secondary
: Colors.transparent,
width: 4,
),
@ -208,8 +229,8 @@ class ChatListView extends StatelessWidget {
size: 32,
fontSize: 12,
),
onPressed: () =>
controller.setActiveSpace(rootSpaces[i].id),
onPressed: () => controller
.setActiveSpace(rootSpaces[i].id),
),
);
},
@ -231,10 +252,12 @@ class ChatListView extends StatelessWidget {
selectedIndex: controller.selectedIndex,
onDestinationSelected:
controller.onDestinationSelected,
destinations: getNavigationDestinations(context),
destinations:
getNavigationDestinations(context),
)
: null,
floatingActionButton: controller.filteredRooms.isNotEmpty &&
floatingActionButton: controller
.filteredRooms.isNotEmpty &&
selectMode == SelectMode.normal
? KeyBoardShortcuts(
keysToPress: {
@ -251,7 +274,8 @@ class ChatListView extends StatelessWidget {
),
),
],
),
);
}),
);
},
);

View File

@ -17,9 +17,13 @@ class HomeserverPickerView extends StatelessWidget {
Widget build(BuildContext context) {
final benchmarkResults = controller.benchmarkResults;
return LoginScaffold(
body: Column(
body: SafeArea(
child: Column(
children: [
HomeserverAppBar(controller: controller),
Padding(
padding: const EdgeInsets.all(12.0),
child: HomeserverAppBar(controller: controller),
),
// display a prominent banner to import session for TOR browser
// users. This feature is just some UX sugar as TOR users are
// usually forced to logout as TOR browser is non-persistent
@ -138,7 +142,8 @@ class HomeserverPickerView extends StatelessWidget {
tag: 'loginButton',
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
backgroundColor:
Theme.of(context).colorScheme.primary,
foregroundColor:
Theme.of(context).colorScheme.onPrimary,
),
@ -156,6 +161,7 @@ class HomeserverPickerView extends StatelessWidget {
),
],
),
),
);
}
}