Skip to content

Commit 960cfd9

Browse files
authored
chore: improve bubble shape and swap chat room from invite-shield to normal room on accept (#76)
1 parent 09868d7 commit 960cfd9

File tree

7 files changed

+44
-17
lines changed

7 files changed

+44
-17
lines changed

lib/chat_room/common/view/chat_room_page.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ class _ChatRoomPageState extends State<ChatRoomPage> {
8686

8787
final unAcceptedDirectChat = watchStream(
8888
(ChatModel m) => m
89-
.getJoinedRoomUpdate(widget.room.id)
90-
.map((room) => widget.room.isUnacceptedDirectChat),
89+
.getUsersStreamOfJoinedRoom(
90+
widget.room,
91+
membershipFilter: [Membership.invite],
92+
)
93+
.map(
94+
(invitedUsers) =>
95+
widget.room.isDirectChat && invitedUsers.isNotEmpty,
96+
),
9197
initialValue: widget.room.isUnacceptedDirectChat,
9298
preserveState: false,
9399
).data;

lib/chat_room/info_drawer/chat_room_info_drawer.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ class ChatRoomInfoDrawer extends StatelessWidget with WatchItMixin {
2121
Widget build(BuildContext context) {
2222
final unAcceptedDirectChat = watchStream(
2323
(ChatModel m) => m
24-
.getJoinedRoomUpdate(room.id)
25-
.map((_) => room.isUnacceptedDirectChat),
24+
.getUsersStreamOfJoinedRoom(
25+
room,
26+
membershipFilter: [Membership.invite],
27+
)
28+
.map((invitedUsers) => room.isDirectChat && invitedUsers.isNotEmpty),
2629
initialValue: room.isUnacceptedDirectChat,
2730
preserveState: false,
2831
).data;

lib/chat_room/timeline/timeline_model.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TimelineModel extends SafeChangeNotifier {
1313

1414
final Map<String, bool> _updatingTimeline = {};
1515
bool getUpdatingTimeline(String? roomId) => _updatingTimeline[roomId] == true;
16-
void setUpdatingTimeline({required String roomId, required bool value}) {
16+
void _setUpdatingTimeline({required String roomId, required bool value}) {
1717
if (_updatingTimeline[roomId] == value) return;
1818
_updatingTimeline[roomId] = value;
1919
notifyListeners();
@@ -24,7 +24,7 @@ class TimelineModel extends SafeChangeNotifier {
2424
int historyCount = 50,
2525
StateFilter? filter,
2626
}) async {
27-
setUpdatingTimeline(roomId: timeline.room.id, value: true);
27+
_setUpdatingTimeline(roomId: timeline.room.id, value: true);
2828
_setTimeline(timeline: timeline);
2929

3030
if (!timeline.room.isArchived) {
@@ -39,7 +39,7 @@ class TimelineModel extends SafeChangeNotifier {
3939
}
4040
}
4141

42-
setUpdatingTimeline(roomId: timeline.room.id, value: false);
42+
_setUpdatingTimeline(roomId: timeline.room.id, value: false);
4343
}
4444

4545
Future<void> trySetReadMarker(Timeline timeline) async {

lib/common/event_x.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ extension EventX on Event {
144144
}
145145
}
146146

147-
enum EventPosition { top, bottom, middle }
147+
enum EventPosition { top, bottom, middle, semanticSingle }

lib/common/room_x.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ extension RoomX on Room {
1616
canChangeStateEvent(EventTypes.RoomPowerLevels);
1717

1818
bool get isUnacceptedDirectChat {
19-
final directChatMatrixID = this.directChatMatrixID;
20-
if (directChatMatrixID != null) {
21-
return unsafeGetUserFromMemoryOrFallback(directChatMatrixID).membership ==
22-
Membership.invite;
19+
if (isDirectChat) {
20+
return getParticipants()
21+
.where((p) => p.membership == Membership.invite)
22+
.isNotEmpty;
2323
}
2424
return false;
2525
}

lib/common/view/ui_constants.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ const Curve kAvatarAnimationCurve = Curves.easeInOut;
2626
const kTypingAvatarSize = 20.0;
2727
const kAvatarDefaultSize = 38.0;
2828

29-
const kBubbleRadius = Radius.circular(4.0);
30-
const kBigBubbleRadius = Radius.circular(8.0);
29+
const kBubbleRadiusValue = 4.0;
30+
const kBigBubbleRadiusValue = 12.0;
31+
const kBubbleRadius = Radius.circular(kBubbleRadiusValue);
32+
const kBigBubbleRadius = Radius.circular(kBigBubbleRadiusValue);
3133

3234
const windowOptions = WindowOptions(
3335
size: Size(1024, 800),

lib/events/view/chat_message_bubble_content.dart

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,25 @@ class ChatMessageBubbleContent extends StatelessWidget {
9191
event.isUserEvent,
9292
context.theme,
9393
),
94-
borderRadius: const BorderRadius.all(
95-
kBigBubbleRadius,
96-
),
94+
borderRadius: switch (eventPosition) {
95+
EventPosition.middle => BorderRadius.circular(
96+
kBubbleRadiusValue,
97+
),
98+
EventPosition.top => const BorderRadius.only(
99+
topLeft: kBubbleRadius,
100+
topRight: kBigBubbleRadius,
101+
bottomLeft: kBubbleRadius,
102+
bottomRight: kBubbleRadius,
103+
),
104+
EventPosition.bottom => const BorderRadius.only(
105+
topLeft: kBubbleRadius,
106+
topRight: kBubbleRadius,
107+
bottomLeft: kBigBubbleRadius,
108+
bottomRight: kBigBubbleRadius,
109+
),
110+
EventPosition.semanticSingle =>
111+
const BorderRadius.all(kBigBubbleRadius),
112+
},
97113
),
98114
child: Column(
99115
crossAxisAlignment: CrossAxisAlignment.start,

0 commit comments

Comments
 (0)