mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 23:09:35 +01:00
design: Nicer navigationrail
This commit is contained in:
parent
b894a4542a
commit
264f36ea59
@ -9,6 +9,7 @@ import 'package:vrouter/vrouter.dart';
|
|||||||
import 'package:fluffychat/config/app_config.dart';
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
import 'package:fluffychat/config/themes.dart';
|
import 'package:fluffychat/config/themes.dart';
|
||||||
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
||||||
|
import 'package:fluffychat/pages/chat_list/navi_rail_item.dart';
|
||||||
import 'package:fluffychat/widgets/avatar.dart';
|
import 'package:fluffychat/widgets/avatar.dart';
|
||||||
import 'package:fluffychat/widgets/unread_rooms_badge.dart';
|
import 'package:fluffychat/widgets/unread_rooms_badge.dart';
|
||||||
import '../../widgets/matrix.dart';
|
import '../../widgets/matrix.dart';
|
||||||
@ -126,91 +127,29 @@ class ChatListView extends StatelessWidget {
|
|||||||
itemCount: rootSpaces.length + destinations.length,
|
itemCount: rootSpaces.length + destinations.length,
|
||||||
itemBuilder: (context, i) {
|
itemBuilder: (context, i) {
|
||||||
if (i < destinations.length) {
|
if (i < destinations.length) {
|
||||||
final isSelected = i == controller.selectedIndex;
|
return NaviRailItem(
|
||||||
return Container(
|
isSelected: i == controller.selectedIndex,
|
||||||
height: 64,
|
onTap: () => controller.onDestinationSelected(i),
|
||||||
width: 64,
|
icon: destinations[i].icon,
|
||||||
decoration: BoxDecoration(
|
selectedIcon: destinations[i].selectedIcon,
|
||||||
border: Border(
|
toolTip: destinations[i].label,
|
||||||
bottom: i == (destinations.length - 1)
|
|
||||||
? BorderSide(
|
|
||||||
width: 1,
|
|
||||||
color: Theme.of(context).dividerColor,
|
|
||||||
)
|
|
||||||
: BorderSide.none,
|
|
||||||
left: BorderSide(
|
|
||||||
color: isSelected
|
|
||||||
? Theme.of(context).colorScheme.primary
|
|
||||||
: Colors.transparent,
|
|
||||||
width: 4,
|
|
||||||
),
|
|
||||||
right: const BorderSide(
|
|
||||||
color: Colors.transparent,
|
|
||||||
width: 4,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: IconButton(
|
|
||||||
color: isSelected
|
|
||||||
? Theme.of(context).colorScheme.secondary
|
|
||||||
: null,
|
|
||||||
icon: CircleAvatar(
|
|
||||||
backgroundColor: isSelected
|
|
||||||
? Theme.of(context).colorScheme.secondary
|
|
||||||
: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.background,
|
|
||||||
foregroundColor: isSelected
|
|
||||||
? Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSecondary
|
|
||||||
: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onBackground,
|
|
||||||
child: i == controller.selectedIndex
|
|
||||||
? destinations[i].selectedIcon ??
|
|
||||||
destinations[i].icon
|
|
||||||
: destinations[i].icon),
|
|
||||||
tooltip: destinations[i].label,
|
|
||||||
onPressed: () =>
|
|
||||||
controller.onDestinationSelected(i),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
i -= destinations.length;
|
i -= destinations.length;
|
||||||
final isSelected =
|
final isSelected =
|
||||||
controller.activeFilter == ActiveFilter.spaces &&
|
controller.activeFilter == ActiveFilter.spaces &&
|
||||||
rootSpaces[i].id == controller.activeSpaceId;
|
rootSpaces[i].id == controller.activeSpaceId;
|
||||||
return Container(
|
return NaviRailItem(
|
||||||
height: 64,
|
toolTip: rootSpaces[i].displayname,
|
||||||
width: 64,
|
isSelected: isSelected,
|
||||||
decoration: BoxDecoration(
|
onTap: () =>
|
||||||
border: Border(
|
controller.setActiveSpace(rootSpaces[i].id),
|
||||||
left: BorderSide(
|
|
||||||
color: isSelected
|
|
||||||
? Theme.of(context).colorScheme.secondary
|
|
||||||
: Colors.transparent,
|
|
||||||
width: 4,
|
|
||||||
),
|
|
||||||
right: const BorderSide(
|
|
||||||
color: Colors.transparent,
|
|
||||||
width: 4,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: IconButton(
|
|
||||||
tooltip: rootSpaces[i].displayname,
|
|
||||||
icon: Avatar(
|
icon: Avatar(
|
||||||
mxContent: rootSpaces[i].avatar,
|
mxContent: rootSpaces[i].avatar,
|
||||||
name: rootSpaces[i].displayname,
|
name: rootSpaces[i].displayname,
|
||||||
size: 32,
|
size: 32,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
onPressed: () =>
|
|
||||||
controller.setActiveSpace(rootSpaces[i].id),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
66
lib/pages/chat_list/navi_rail_item.dart
Normal file
66
lib/pages/chat_list/navi_rail_item.dart
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
|
|
||||||
|
class NaviRailItem extends StatelessWidget {
|
||||||
|
final String toolTip;
|
||||||
|
final bool isSelected;
|
||||||
|
final void Function() onTap;
|
||||||
|
final Widget icon;
|
||||||
|
final Widget? selectedIcon;
|
||||||
|
|
||||||
|
const NaviRailItem({
|
||||||
|
required this.toolTip,
|
||||||
|
required this.isSelected,
|
||||||
|
required this.onTap,
|
||||||
|
required this.icon,
|
||||||
|
this.selectedIcon,
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 64,
|
||||||
|
width: 64,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Positioned(
|
||||||
|
top: 16,
|
||||||
|
bottom: 16,
|
||||||
|
left: 0,
|
||||||
|
child: AnimatedContainer(
|
||||||
|
width: isSelected ? 4 : 0,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
borderRadius: const BorderRadius.only(
|
||||||
|
topRight: Radius.circular(90),
|
||||||
|
bottomRight: Radius.circular(90),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: IconButton(
|
||||||
|
onPressed: onTap,
|
||||||
|
tooltip: toolTip,
|
||||||
|
icon: Material(
|
||||||
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||||
|
color: isSelected
|
||||||
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
|
: Theme.of(context).colorScheme.background,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8.0,
|
||||||
|
vertical: 8.0,
|
||||||
|
),
|
||||||
|
child: isSelected ? selectedIcon ?? icon : icon,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user