Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! TW-1690: Handle public rooms actions
Browse files Browse the repository at this point in the history
  • Loading branch information
hieutbui committed May 25, 2024
1 parent 2ca481d commit 8102efb
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 98 deletions.
73 changes: 35 additions & 38 deletions lib/pages/search/public_room/empty_search_public_room_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,44 @@ class EmptySearchPublicRoomWidget extends StatelessWidget {
Widget build(BuildContext context) {
return Padding(
padding: SearchPublicRoomViewStyle.paddingListItem,
child: Padding(
padding: SearchPublicRoomViewStyle.paddingInsideListItem,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: SearchPublicRoomViewStyle.paddingAvatar,
child: Avatar(
name: genericSearchTerm,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: SearchPublicRoomViewStyle.paddingAvatar,
child: Avatar(
name: genericSearchTerm,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
genericSearchTerm,
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style: SearchPublicRoomViewStyle.roomNameTextStyle,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
genericSearchTerm,
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style: SearchPublicRoomViewStyle.roomNameTextStyle,
),
const SizedBox(
height: SearchPublicRoomViewStyle.nameToButtonSpace,
),
TwakeTextButton(
message: L10n.of(context)!.joinRoom,
styleMessage:
SearchPublicRoomViewStyle.joinButtonLabelStyle(context),
paddingAll: SearchPublicRoomViewStyle.paddingButton,
onTap: onTapJoin,
buttonDecoration:
SearchPublicRoomViewStyle.actionButtonDecoration(
context,
),
const SizedBox(
height: SearchPublicRoomViewStyle.nameToButtonSpace,
),
TwakeTextButton(
message: L10n.of(context)!.joinRoom,
styleMessage:
SearchPublicRoomViewStyle.joinButtonLabelStyle(context),
paddingAll: SearchPublicRoomViewStyle.paddingButton,
onTap: onTapJoin,
buttonDecoration:
SearchPublicRoomViewStyle.actionButtonDecoration(
context,
),
),
],
),
),
],
),
],
),
),
],
),
);
}
Expand Down
100 changes: 53 additions & 47 deletions lib/pages/search/public_room/search_public_room_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,56 +52,62 @@ class SearchPublicRoomList extends StatelessWidget {
.getAction(context, room);
return Padding(
padding: SearchPublicRoomViewStyle.paddingListItem,
child: Padding(
padding: SearchPublicRoomViewStyle.paddingInsideListItem,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: SearchPublicRoomViewStyle.paddingAvatar,
child: Avatar(
mxContent: room.avatarUrl,
name: room.name,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: SearchPublicRoomViewStyle.paddingAvatar,
child: Avatar(
mxContent: room.avatarUrl,
name: room.name,
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
room.name ?? room.roomId,
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style:
SearchPublicRoomViewStyle.roomNameTextStyle,
),
const SizedBox(
height:
SearchPublicRoomViewStyle.nameToButtonSpace,
),
Text(
room.canonicalAlias ?? room.roomId,
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style:
SearchPublicRoomViewStyle.roomAliasTextStyle,
),
],
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
room.name ?? room.roomId,
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style:
SearchPublicRoomViewStyle.roomNameTextStyle,
),
const SizedBox(
height:
SearchPublicRoomViewStyle.nameToButtonSpace,
),
if (action != null)
TwakeTextButton(
message: action.getLabel(context),
styleMessage: action.getLabelStyle(context),
paddingAll:
SearchPublicRoomViewStyle.paddingButton,
onTap: () => searchController
.searchPublicRoomController
.handlePublicRoomActions(
context,
room,
action,
),
hoverColor: Colors.transparent,
buttonDecoration: SearchPublicRoomViewStyle
.actionButtonDecoration(context),
),
],
),
if (action != null)
TwakeTextButton(
message: action.getLabel(context),
styleMessage: action.getLabelStyle(context),
paddingAll: SearchPublicRoomViewStyle.paddingButton,
onTap: () => searchController
.searchPublicRoomController
.handlePublicRoomActions(
context,
room,
action,
),
hoverColor: Colors.transparent,
buttonDecoration:
SearchPublicRoomViewStyle.actionButtonDecoration(
context,
),
),
],
),
],
),
);
}),
Expand Down
10 changes: 7 additions & 3 deletions lib/pages/search/public_room/search_public_room_view_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ class SearchPublicRoomViewStyle {

static const double paddingButton = 12.0;

static const EdgeInsetsGeometry paddingListItem = EdgeInsets.all(8.0);

static const EdgeInsetsGeometry paddingInsideListItem = EdgeInsets.all(8.0);
static const EdgeInsetsGeometry paddingListItem = EdgeInsets.all(16.0);

static const EdgeInsetsGeometry paddingAvatar = EdgeInsets.only(right: 12.0);

static TextStyle roomNameTextStyle =
LinagoraTextStyle.material().bodyMedium2.copyWith(
color: LinagoraSysColors.material().onSurface,
fontFamily: GoogleFonts.inter().fontFamily,
);

static TextStyle roomAliasTextStyle =
LinagoraTextStyle.material().bodyMedium3.copyWith(
color: LinagoraSysColors.material().onSurface,
fontFamily: GoogleFonts.inter().fontFamily,
Expand Down
12 changes: 2 additions & 10 deletions test/utils/string_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,7 @@ void main() {
for (final entry in testMap.entries) {
test('Testing: ${entry.key} => Expected: ${entry.value}', () {
final result = entry.key.isRoomAlias();
if (entry.value) {
expect(result, isTrue);
} else {
expect(result, isFalse);
}
expect(result, entry.value);
});
}
});
Expand Down Expand Up @@ -430,11 +426,7 @@ void main() {
for (final entry in testMap.entries) {
test('Testing: ${entry.key} => Expected: ${entry.value}', () {
final result = entry.key.isRoomId();
if (entry.value) {
expect(result, isTrue);
} else {
expect(result, isFalse);
}
expect(result, entry.value);
});
}
});
Expand Down

0 comments on commit 8102efb

Please sign in to comment.