chore: Follow up fix chat list

This commit is contained in:
Krille Fear 2022-12-29 10:26:01 +01:00
parent 220dda715a
commit 05285b46d8
3 changed files with 22 additions and 27 deletions

View File

@ -3,13 +3,13 @@ import 'package:flutter/material.dart';
import 'package:animations/animations.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/pages/chat_list/chat_list_item.dart';
import 'package:fluffychat/pages/chat_list/search_title.dart';
import 'package:fluffychat/pages/chat_list/space_view.dart';
import 'package:fluffychat/pages/chat_list/stories_header.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/client_stories_extension.dart';
import 'package:fluffychat/utils/stream_extension.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/profile_bottom_sheet.dart';
@ -61,9 +61,10 @@ class ChatListViewBody extends StatelessWidget {
if (controller.waitForFirstSync && client.prevBatch != null) {
final rooms = controller.filteredRooms;
final displayStoriesHeader = {
ActiveFilter.allChats,
ActiveFilter.messages,
}.contains(controller.activeFilter);
ActiveFilter.allChats,
ActiveFilter.messages,
}.contains(controller.activeFilter) &&
client.storiesRooms.isNotEmpty;
return ListView.builder(
controller: controller.scrollController,
// add +1 space below in order to properly scroll below the spaces bar
@ -184,27 +185,11 @@ class ChatListViewBody extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 32),
Image.asset(
'assets/start_chat.png',
height: 256,
),
Divider(
height: 1,
color: Theme.of(context)
.colorScheme
.onBackground,
),
const SizedBox(height: 32),
FloatingActionButton.extended(
backgroundColor:
Theme.of(context).colorScheme.primary,
foregroundColor:
Theme.of(context).colorScheme.onPrimary,
icon: const Icon(Icons.edit_outlined),
onPressed: () =>
VRouter.of(context).to('/newprivatechat'),
label: Text(L10n.of(context)!.startFirstChat),
),
const Divider(height: 1),
],
),
),

View File

@ -238,8 +238,11 @@ class ChatListView extends StatelessWidget {
destinations: getNavigationDestinations(context),
)
: null,
floatingActionButton: controller.filteredRooms.isNotEmpty &&
selectMode == SelectMode.normal
floatingActionButtonLocation:
controller.filteredRooms.isEmpty
? FloatingActionButtonLocation.centerFloat
: null,
floatingActionButton: selectMode == SelectMode.normal
? KeyBoardShortcuts(
keysToPress: {
LogicalKeyboardKey.controlLeft,
@ -249,7 +252,8 @@ class ChatListView extends StatelessWidget {
VRouter.of(context).to('/newprivatechat'),
helpLabel: L10n.of(context)!.newChat,
child: StartChatFloatingActionButton(
controller: controller),
controller: controller,
),
)
: null,
),

View File

@ -42,7 +42,9 @@ class StartChatFloatingActionButton extends StatelessWidget {
switch (controller.activeFilter) {
case ActiveFilter.allChats:
case ActiveFilter.messages:
return L10n.of(context)!.newChat;
return controller.filteredRooms.isEmpty
? L10n.of(context)!.startFirstChat
: L10n.of(context)!.newChat;
case ActiveFilter.groups:
return L10n.of(context)!.newGroup;
case ActiveFilter.spaces:
@ -55,7 +57,11 @@ class StartChatFloatingActionButton extends StatelessWidget {
return AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
width: controller.scrolledToTop ? 144 : 64,
width: controller.filteredRooms.isEmpty
? null
: controller.scrolledToTop
? 144
: 64,
child: controller.scrolledToTop
? FloatingActionButton.extended(
backgroundColor: Theme.of(context).colorScheme.primary,