mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 06:55:12 +00:00
chore: nicer bottom sheets
This commit is contained in:
parent
22cfdd7689
commit
d71d633cce
4 changed files with 33 additions and 32 deletions
|
@ -234,7 +234,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
|
|||
|
||||
void sendAction([_]) async {
|
||||
final userId = widget.user?.id ?? widget.profile?.userId;
|
||||
final client = Matrix.of(context).client;
|
||||
final client = Matrix.of(widget.outerContext).client;
|
||||
if (userId == null) throw ('user or profile must not be null!');
|
||||
|
||||
final input = sendController.text.trim();
|
||||
|
|
|
@ -207,6 +207,29 @@ class UserBottomSheetView extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
PresenceBuilder(
|
||||
userId: userId,
|
||||
client: client,
|
||||
builder: (context, presence) {
|
||||
final status = presence?.statusMsg;
|
||||
if (status == null || status.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return ListTile(
|
||||
title: SelectableLinkify(
|
||||
text: status,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
options: const LinkifyOptions(humanize: false),
|
||||
linkStyle: const TextStyle(
|
||||
color: Colors.blueAccent,
|
||||
decorationColor: Colors.blueAccent,
|
||||
),
|
||||
onOpen: (url) =>
|
||||
UrlLauncher(context, url.url).launchUrl(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (userId != client.userID)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
|
@ -250,29 +273,6 @@ class UserBottomSheetView extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
PresenceBuilder(
|
||||
userId: userId,
|
||||
client: client,
|
||||
builder: (context, presence) {
|
||||
final status = presence?.statusMsg;
|
||||
if (status == null || status.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return ListTile(
|
||||
title: SelectableLinkify(
|
||||
text: status,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
options: const LinkifyOptions(humanize: false),
|
||||
linkStyle: const TextStyle(
|
||||
color: Colors.blueAccent,
|
||||
decorationColor: Colors.blueAccent,
|
||||
),
|
||||
onOpen: (url) =>
|
||||
UrlLauncher(context, url.url).launchUrl(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (controller.widget.onMention != null)
|
||||
ListTile(
|
||||
leading: const Icon(Icons.alternate_email_outlined),
|
||||
|
|
|
@ -8,18 +8,19 @@ Future<T?> showAdaptiveBottomSheet<T>({
|
|||
required Widget Function(BuildContext) builder,
|
||||
bool isDismissible = true,
|
||||
bool isScrollControlled = true,
|
||||
double maxHeight = 480.0,
|
||||
double maxHeight = 512,
|
||||
bool useRootNavigator = true,
|
||||
}) =>
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: builder,
|
||||
// this sadly is ugly on desktops but otherwise breaks `.of(context)` calls
|
||||
useRootNavigator: false,
|
||||
useRootNavigator: useRootNavigator,
|
||||
isDismissible: isDismissible,
|
||||
isScrollControlled: isScrollControlled,
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: maxHeight,
|
||||
maxWidth: FluffyThemes.columnWidth * 1.5,
|
||||
maxWidth: FluffyThemes.columnWidth * 1.25,
|
||||
),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
shape: const RoundedRectangleBorder(
|
||||
|
|
|
@ -64,17 +64,17 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
|
||||
bool _testRoom(PublicRoomsChunk r) => r.canonicalAlias == roomAlias;
|
||||
|
||||
Future<PublicRoomsChunk> _search(BuildContext context) async {
|
||||
Future<PublicRoomsChunk> _search() async {
|
||||
final chunk = this.chunk;
|
||||
if (chunk != null) return chunk;
|
||||
final query = await Matrix.of(context).client.queryPublicRooms(
|
||||
final query = await Matrix.of(outerContext).client.queryPublicRooms(
|
||||
server: roomAlias!.domain,
|
||||
filter: PublicRoomQueryFilter(
|
||||
genericSearchTerm: roomAlias,
|
||||
),
|
||||
);
|
||||
if (!query.chunk.any(_testRoom)) {
|
||||
throw (L10n.of(context)!.noRoomsFound);
|
||||
throw (L10n.of(outerContext)!.noRoomsFound);
|
||||
}
|
||||
return query.chunk.firstWhere(_testRoom);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
body: FutureBuilder<PublicRoomsChunk>(
|
||||
future: _search(context),
|
||||
future: _search(),
|
||||
builder: (context, snapshot) {
|
||||
final profile = snapshot.data;
|
||||
return ListView(
|
||||
|
@ -142,7 +142,7 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
onPressed: () => _joinRoom(context),
|
||||
label: Text(
|
||||
chunk?.joinRule == 'knock' &&
|
||||
Matrix.of(context)
|
||||
Matrix.of(outerContext)
|
||||
.client
|
||||
.getRoomById(chunk!.roomId) ==
|
||||
null
|
||||
|
|
Loading…
Reference in a new issue