feat: Use SalomonBottomBar

This commit is contained in:
Krille Fear 2021-11-15 07:24:05 +01:00
parent 10480ec408
commit ae0a720d16
4 changed files with 46 additions and 38 deletions

View File

@ -56,12 +56,7 @@ class ChatListView extends StatelessWidget {
? null ? null
: selectMode == SelectMode.select : selectMode == SelectMode.select
? [ ? [
if (controller.spaces.isNotEmpty && if (controller.spaces.isNotEmpty)
!Matrix.of(context)
.client
.getRoomById(
controller.selectedRoomIds.single)
.isDirectChat)
IconButton( IconButton(
tooltip: L10n.of(context).addToSpace, tooltip: L10n.of(context).addToSpace,
icon: const Icon(Icons.group_work_outlined), icon: const Icon(Icons.group_work_outlined),

View File

@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:salomon_bottom_bar/salomon_bottom_bar.dart';
import 'package:fluffychat/pages/chat_list/chat_list.dart'; import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/avatar.dart';
@ -17,40 +18,44 @@ class SpacesBottomBar extends StatelessWidget {
: controller.spaces : controller.spaces
.indexWhere((space) => controller.activeSpaceId == space.id) + .indexWhere((space) => controller.activeSpaceId == space.id) +
1; 1;
return BottomNavigationBar( return Material(
currentIndex: currentIndex, color: Theme.of(context).appBarTheme.backgroundColor,
backgroundColor: Theme.of(context).scaffoldBackgroundColor, elevation: 6,
landscapeLayout: BottomNavigationBarLandscapeLayout.spread, child: SalomonBottomBar(
onTap: (i) => controller.setActiveSpaceId( itemPadding: const EdgeInsets.all(8),
context, currentIndex: currentIndex,
i == 0 ? null : controller.spaces[i - 1].id, onTap: (i) => controller.setActiveSpaceId(
), context,
items: [ i == 0 ? null : controller.spaces[i - 1].id,
BottomNavigationBarItem(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
icon: const Icon(CupertinoIcons.chat_bubble_2),
label: L10n.of(context).allChats,
), ),
...controller.spaces items: [
.map((space) => BottomNavigationBarItem( SalomonBottomBarItem(
icon: InkWell( icon: const Icon(CupertinoIcons.chat_bubble_2),
borderRadius: BorderRadius.circular(28), activeIcon: const Icon(CupertinoIcons.chat_bubble_2_fill),
onTap: () => controller.setActiveSpaceId( title: Text(L10n.of(context).allChats),
context, ),
space.id, ...controller.spaces
.map((space) => SalomonBottomBarItem(
icon: InkWell(
borderRadius: BorderRadius.circular(28),
onTap: () => controller.setActiveSpaceId(
context,
space.id,
),
onLongPress: () =>
controller.editSpace(context, space.id),
child: Avatar(
space.avatar,
space.displayname,
size: 24,
fontSize: 12,
),
), ),
onLongPress: () => controller.editSpace(context, space.id), title: Text(space.displayname),
child: Avatar( ))
space.avatar, .toList(),
space.displayname, ],
size: 24, ),
fontSize: 12,
),
),
label: space.displayname,
))
.toList(),
],
); );
} }
} }

View File

@ -1152,6 +1152,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.26.0" version: "0.26.0"
salomon_bottom_bar:
dependency: "direct main"
description:
name: salomon_bottom_bar
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
scroll_to_index: scroll_to_index:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -61,6 +61,7 @@ dependencies:
qr_flutter: ^4.0.0 qr_flutter: ^4.0.0
receive_sharing_intent: ^1.4.5 receive_sharing_intent: ^1.4.5
record: ^3.0.0 record: ^3.0.0
salomon_bottom_bar: ^3.1.0
scroll_to_index: ^2.1.0 scroll_to_index: ^2.1.0
sembast_web: ^2.0.1+1 sembast_web: ^2.0.1+1
sentry: ^6.0.1 sentry: ^6.0.1