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 {
|
void sendAction([_]) async {
|
||||||
final userId = widget.user?.id ?? widget.profile?.userId;
|
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!');
|
if (userId == null) throw ('user or profile must not be null!');
|
||||||
|
|
||||||
final input = sendController.text.trim();
|
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)
|
if (userId != client.userID)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
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)
|
if (controller.widget.onMention != null)
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.alternate_email_outlined),
|
leading: const Icon(Icons.alternate_email_outlined),
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,19 @@ Future<T?> showAdaptiveBottomSheet<T>({
|
||||||
required Widget Function(BuildContext) builder,
|
required Widget Function(BuildContext) builder,
|
||||||
bool isDismissible = true,
|
bool isDismissible = true,
|
||||||
bool isScrollControlled = true,
|
bool isScrollControlled = true,
|
||||||
double maxHeight = 480.0,
|
double maxHeight = 512,
|
||||||
|
bool useRootNavigator = true,
|
||||||
}) =>
|
}) =>
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: builder,
|
builder: builder,
|
||||||
// this sadly is ugly on desktops but otherwise breaks `.of(context)` calls
|
// this sadly is ugly on desktops but otherwise breaks `.of(context)` calls
|
||||||
useRootNavigator: false,
|
useRootNavigator: useRootNavigator,
|
||||||
isDismissible: isDismissible,
|
isDismissible: isDismissible,
|
||||||
isScrollControlled: isScrollControlled,
|
isScrollControlled: isScrollControlled,
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxHeight: maxHeight,
|
maxHeight: maxHeight,
|
||||||
maxWidth: FluffyThemes.columnWidth * 1.5,
|
maxWidth: FluffyThemes.columnWidth * 1.25,
|
||||||
),
|
),
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
|
|
|
||||||
|
|
@ -64,17 +64,17 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
||||||
|
|
||||||
bool _testRoom(PublicRoomsChunk r) => r.canonicalAlias == roomAlias;
|
bool _testRoom(PublicRoomsChunk r) => r.canonicalAlias == roomAlias;
|
||||||
|
|
||||||
Future<PublicRoomsChunk> _search(BuildContext context) async {
|
Future<PublicRoomsChunk> _search() async {
|
||||||
final chunk = this.chunk;
|
final chunk = this.chunk;
|
||||||
if (chunk != null) return 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,
|
server: roomAlias!.domain,
|
||||||
filter: PublicRoomQueryFilter(
|
filter: PublicRoomQueryFilter(
|
||||||
genericSearchTerm: roomAlias,
|
genericSearchTerm: roomAlias,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (!query.chunk.any(_testRoom)) {
|
if (!query.chunk.any(_testRoom)) {
|
||||||
throw (L10n.of(context)!.noRoomsFound);
|
throw (L10n.of(outerContext)!.noRoomsFound);
|
||||||
}
|
}
|
||||||
return query.chunk.firstWhere(_testRoom);
|
return query.chunk.firstWhere(_testRoom);
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +108,7 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: FutureBuilder<PublicRoomsChunk>(
|
body: FutureBuilder<PublicRoomsChunk>(
|
||||||
future: _search(context),
|
future: _search(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final profile = snapshot.data;
|
final profile = snapshot.data;
|
||||||
return ListView(
|
return ListView(
|
||||||
|
|
@ -142,7 +142,7 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
||||||
onPressed: () => _joinRoom(context),
|
onPressed: () => _joinRoom(context),
|
||||||
label: Text(
|
label: Text(
|
||||||
chunk?.joinRule == 'knock' &&
|
chunk?.joinRule == 'knock' &&
|
||||||
Matrix.of(context)
|
Matrix.of(outerContext)
|
||||||
.client
|
.client
|
||||||
.getRoomById(chunk!.roomId) ==
|
.getRoomById(chunk!.roomId) ==
|
||||||
null
|
null
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue