Skip to content

Commit b95f5a4

Browse files
authored
feat: improve spaces UI and handling (#93)
1 parent 750aaf4 commit b95f5a4

29 files changed

+372
-409
lines changed

.fvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"flutter": "3.35.0"
2+
"flutter": "3.35.4"
33
}

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"yaml.schemaStore.enable": false,
3-
"dart.flutterSdkPath": ".fvm/versions/3.35.0"
3+
"dart.flutterSdkPath": ".fvm/versions/3.35.4"
44
}

lib/chat_master/view/chat_master_active_space_info.dart

Lines changed: 0 additions & 72 deletions
This file was deleted.

lib/chat_master/view/chat_master_detail_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@ class _ChatMasterDetailPageState extends State<ChatMasterDetailPage> {
104104
snapshot.connectionState == ConnectionState.done
105105
? Row(
106106
children: [
107-
if (context.showSideBar)
107+
if (context.showSideBar) ...[
108108
const SizedBox(
109109
width: kSideBarWith,
110110
child: ChatMasterSidePanel(),
111111
),
112+
],
112113
if (context.showSideBar)
113114
const VerticalDivider(width: 0, thickness: 0),
114115
if (selectedRoom == null)

lib/chat_master/view/chat_master_list_filter_bar.dart

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,25 @@ class ChatMasterListFilterBar extends StatelessWidget with WatchItMixin {
2222
child: YaruChoiceChipBar(
2323
showCheckMarks: false,
2424
shrinkWrap: false,
25+
clearOnSelect: false,
26+
selectedFirst: false,
2527
style: YaruChoiceChipBarStyle.stack,
26-
labels: RoomsFilter.values
27-
.map((e) => Text(e.localize(context.l10n)))
28+
labels: RoomsFilter.shownValues
29+
.map(
30+
(e) => Tooltip(
31+
message: e.localize(context.l10n),
32+
child: Icon(
33+
e.iconData,
34+
semanticLabel: e.localize(context.l10n),
35+
),
36+
),
37+
)
38+
.toList(),
39+
isSelected: RoomsFilter.shownValues
40+
.map((e) => e == roomsFilter)
2841
.toList(),
29-
isSelected: RoomsFilter.values.map((e) => e == roomsFilter).toList(),
3042
onSelected: (i) =>
31-
di<ChatModel>().setRoomsFilter(RoomsFilter.values[i]),
43+
di<ChatModel>().setRoomsFilter(RoomsFilter.shownValues[i]),
3244
),
3345
);
3446
}

lib/chat_master/view/chat_master_panel.dart

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:flutter/material.dart';
2-
import 'package:future_loading_dialog/future_loading_dialog.dart';
32
import 'package:watch_it/watch_it.dart';
43
import 'package:yaru/yaru.dart';
54

@@ -25,10 +24,6 @@ class ChatMasterSidePanel extends StatelessWidget with WatchItMixin {
2524
Widget build(BuildContext context) {
2625
final l10n = context.l10n;
2726
final searchActive = watchPropertyValue((SearchModel m) => m.searchActive);
28-
final archiveActive = watchPropertyValue((ChatModel m) => m.archiveActive);
29-
30-
final roomsFilter = watchPropertyValue((ChatModel m) => m.roomsFilter);
31-
final chatModel = di<ChatModel>();
3227

3328
return Material(
3429
color: getPanelBg(context.theme),
@@ -37,9 +32,18 @@ class ChatMasterSidePanel extends StatelessWidget with WatchItMixin {
3732
const ChatMasterTitleBar(),
3833
if (searchActive) const ChatRoomsSearchField(),
3934
const ChatMasterListFilterBar(),
40-
if (roomsFilter == RoomsFilter.spaces && !archiveActive)
41-
const ChatSpaceFilter(),
42-
const Expanded(child: ChatRoomsList()),
35+
Expanded(
36+
child: Row(
37+
children: [
38+
ChatSpaceFilter(
39+
show: watchPropertyValue(
40+
(ChatModel m) => m.roomsFilter == RoomsFilter.spaces,
41+
),
42+
),
43+
const Expanded(child: ChatRoomsList()),
44+
],
45+
),
46+
),
4347
Padding(
4448
padding: const EdgeInsets.symmetric(vertical: kMediumPadding),
4549
child: Stack(
@@ -53,19 +57,6 @@ class ChatMasterSidePanel extends StatelessWidget with WatchItMixin {
5357
builder: (context) => const ChatSettingsDialog(),
5458
),
5559
),
56-
Positioned(
57-
right: kMediumPadding,
58-
child: IconButton(
59-
tooltip: context.l10n.archive,
60-
selectedIcon: const Icon(YaruIcons.trash_filled),
61-
isSelected: archiveActive,
62-
onPressed: () => showFutureLoadingDialog(
63-
context: context,
64-
future: chatModel.toggleArchive,
65-
),
66-
icon: const Icon(YaruIcons.trash),
67-
),
68-
),
6960
],
7061
),
7162
),

lib/chat_master/view/chat_master_title_bar.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:future_loading_dialog/future_loading_dialog.dart';
23
import 'package:watch_it/watch_it.dart';
34
import 'package:yaru/yaru.dart';
45

@@ -37,13 +38,22 @@ class ChatMasterTitleBar extends StatelessWidget with WatchItMixin {
3738
const ChatMasterNewChatPopupMenuButton()
3839
else
3940
const ChatMasterClearArchiveButton(),
40-
4141
IconButton(
4242
tooltip: context.l10n.search,
4343
isSelected: searchActive,
4444
onPressed: searchModel.toggleSearch,
4545
icon: const Icon(YaruIcons.search),
4646
),
47+
IconButton(
48+
tooltip: context.l10n.archive,
49+
selectedIcon: const Icon(YaruIcons.trash_filled),
50+
isSelected: watchPropertyValue((ChatModel m) => m.archiveActive),
51+
onPressed: () => showFutureLoadingDialog(
52+
context: context,
53+
future: di<ChatModel>().toggleArchive,
54+
),
55+
icon: const Icon(YaruIcons.trash),
56+
),
4757
],
4858
),
4959
);

lib/chat_master/view/chat_rooms_list.dart

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:watch_it/watch_it.dart';
33

44
import '../../common/chat_model.dart';
5-
import '../../common/rooms_filter.dart';
6-
import 'chat_master_active_space_info.dart';
75
import 'chat_room_master_tile.dart';
8-
import 'chat_space_control_panel.dart';
9-
import 'chat_spaces_search_list.dart';
106

117
class ChatRoomsList extends StatelessWidget with WatchItMixin {
128
const ChatRoomsList({super.key});
@@ -21,17 +17,12 @@ class ChatRoomsList extends StatelessWidget with WatchItMixin {
2117
).data ??
2218
di<ChatModel>().filteredRooms;
2319
watchPropertyValue((ChatModel m) => m.filteredRoomsQuery);
24-
final roomsFilter = watchPropertyValue((ChatModel m) => m.roomsFilter);
20+
watchPropertyValue((ChatModel m) => m.roomsFilter);
2521
watchPropertyValue((ChatModel m) => m.archiveActive);
26-
final activeSpace = watchPropertyValue((ChatModel m) => m.activeSpace);
22+
watchPropertyValue((ChatModel m) => m.activeSpace);
2723

2824
return CustomScrollView(
2925
slivers: [
30-
if (activeSpace != null && roomsFilter == RoomsFilter.spaces) ...[
31-
const ChatMasterActiveSpaceInfo(),
32-
const ChatSpaceControlPanel(),
33-
const ChatSpacesSearchList(),
34-
],
3526
SliverList.builder(
3627
itemCount: filteredRooms.length,
3728
itemBuilder: (context, i) {

lib/chat_master/view/chat_space_control_panel.dart

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:watch_it/watch_it.dart';
3+
import 'package:yaru/yaru.dart';
4+
5+
import '../../common/chat_model.dart';
6+
import '../../common/search_model.dart';
7+
import '../../common/view/ui_constants.dart';
8+
import '../../l10n/l10n.dart';
9+
10+
class ChatSpaceDiscoverButton extends StatelessWidget with WatchItMixin {
11+
const ChatSpaceDiscoverButton({super.key});
12+
13+
@override
14+
Widget build(BuildContext context) {
15+
final activeSpace = watchPropertyValue((ChatModel m) => m.activeSpace);
16+
final spaceSearch = watchPropertyValue((SearchModel m) => m.spaceSearch);
17+
return Padding(
18+
padding: const EdgeInsets.symmetric(
19+
horizontal: kBigPadding + kSmallPadding,
20+
),
21+
child: Row(
22+
children: [
23+
Expanded(
24+
child: ElevatedButton.icon(
25+
label: Text(context.l10n.discover),
26+
onPressed: spaceSearch == null || activeSpace == null
27+
? null
28+
: () => di<SearchModel>().searchSpaces(
29+
activeSpace,
30+
onFail: (error) {},
31+
),
32+
icon: const Icon(YaruIcons.compass),
33+
),
34+
),
35+
],
36+
),
37+
);
38+
}
39+
}

0 commit comments

Comments
 (0)