add theming workaround for navigation_rail_m3e

This commit is contained in:
Henry Hiles 2026-08-22 15:12:35 -04:00
commit a090d88a23
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 189 additions and 167 deletions

View file

@ -12,6 +12,9 @@ import "package:nexus/widgets/divider_widget.dart";
import "package:nexus/widgets/join_dialog.dart"; import "package:nexus/widgets/join_dialog.dart";
import "package:nexus/widgets/room_menu.dart"; import "package:nexus/widgets/room_menu.dart";
// Needed for navigation_rail_m3e (#65).
import "package:flutter/material.dart" as old_mat;
class const Sidebar({required final bool isDesktop, super.key}) class const Sidebar({required final bool isDesktop, super.key})
extends HookConsumerWidget { extends HookConsumerWidget {
@override @override
@ -72,8 +75,10 @@ class const Sidebar({required final bool isDesktop, super.key})
shape: Border(), shape: Border(),
child: Row( child: Row(
children: [ children: [
Theme( MaterialUiCompatibilityBridge(
data: Theme.of(context).copyWith( child: Builder(
builder: (context) => old_mat.Theme(
data: old_mat.Theme.of(context).copyWith(
extensions: [ extensions: [
NavigationRailM3ETheme( NavigationRailM3ETheme(
itemCollapsedHeight: 48, itemCollapsedHeight: 48,
@ -109,20 +114,24 @@ class const Sidebar({required final bool isDesktop, super.key})
0, 0,
(previousValue, room) => (previousValue, room) =>
previousValue + previousValue +
(room.metadata?.unreadNotifications ?? 0), (room.metadata?.unreadNotifications ??
0),
)) { )) {
0 => 0 =>
space.children space.children
.addAll( .addAll(
space.subSpaces space.subSpaces
.map( .map(
(element) => element.children, (element) =>
element.children,
) )
.flattened, .flattened,
) )
.any( .any(
(room) => (room) =>
room.metadata?.unreadMessages != room
.metadata
?.unreadMessages !=
0, 0,
) )
? 0 ? 0
@ -159,7 +168,9 @@ class const Sidebar({required final bool isDesktop, super.key})
builder: (_) => JoinDialog(ref), builder: (_) => JoinDialog(ref),
), ),
child: ListTile( child: ListTile(
title: Text("Join an existing room (or space)"), title: Text(
"Join an existing room (or space)",
),
leading: Icon(Icons.numbers), leading: Icon(Icons.numbers),
), ),
), ),
@ -192,6 +203,9 @@ class const Sidebar({required final bool isDesktop, super.key})
), ),
), ),
), ),
),
),
Expanded( Expanded(
child: Scaffold( child: Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
@ -217,8 +231,10 @@ class const Sidebar({required final bool isDesktop, super.key})
), ),
], ],
), ),
body: Theme( body: MaterialUiCompatibilityBridge(
data: Theme.of(context).copyWith( child: Builder(
builder: (context) => old_mat.Theme(
data: old_mat.Theme.of(context).copyWith(
extensions: [ extensions: [
NavigationRailM3ETheme( NavigationRailM3ETheme(
itemExpandedHeight: 48, itemExpandedHeight: 48,
@ -237,7 +253,9 @@ class const Sidebar({required final bool isDesktop, super.key})
header: selectedSpace.room == null header: selectedSpace.room == null
? null ? null
: DividerWidget(Text("Rooms")), : DividerWidget(Text("Rooms")),
destinations: roomsToDestinations(selectedSpace.children), destinations: roomsToDestinations(
selectedSpace.children,
),
), ),
for (final subSpace in selectedSpace.subSpaces) for (final subSpace in selectedSpace.subSpaces)
.new( .new(
@ -264,7 +282,9 @@ class const Sidebar({required final bool isDesktop, super.key})
], ],
), ),
), ),
destinations: roomsToDestinations(subSpace.children), destinations: roomsToDestinations(
subSpace.children,
),
), ),
], ],
onDestinationSelected: (value) { onDestinationSelected: (value) {
@ -282,6 +302,8 @@ class const Sidebar({required final bool isDesktop, super.key})
), ),
), ),
), ),
),
),
], ],
), ),
); );

View file

@ -1004,7 +1004,7 @@ packages:
description: description:
path: "packages/navigation_rail_m3e" path: "packages/navigation_rail_m3e"
ref: HEAD ref: HEAD
resolved-ref: c9edb0be7251e1a31e2336444f00557eb93ca09d resolved-ref: da860a413d5cf78b9c9c967215250bcdbfe5191d
url: "https://github.com/Henry-Hiles/material_3_expressive" url: "https://github.com/Henry-Hiles/material_3_expressive"
source: git source: git
version: "0.3.5" version: "0.3.5"