mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 06:52:35 +01:00
fix: Hide pinned events if event is not accessable or loading
This commit is contained in:
parent
2f1dc8dc15
commit
d1117e152e
@ -60,82 +60,68 @@ class PinnedEvents extends StatelessWidget {
|
|||||||
? snapshot.data?.last
|
? snapshot.data?.last
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (event != null && pinnedEvents != null) {
|
if (event == null || pinnedEvents == null) {
|
||||||
final fontSize =
|
return Container();
|
||||||
AppConfig.messageFontSize * AppConfig.fontSizeFactor;
|
}
|
||||||
return Material(
|
|
||||||
color: Theme.of(context).appBarTheme.backgroundColor,
|
final fontSize = AppConfig.messageFontSize * AppConfig.fontSizeFactor;
|
||||||
elevation: Theme.of(context).appBarTheme.elevation ?? 10,
|
return Material(
|
||||||
shadowColor: Theme.of(context).appBarTheme.shadowColor,
|
color: Theme.of(context).appBarTheme.backgroundColor,
|
||||||
child: InkWell(
|
elevation: Theme.of(context).appBarTheme.elevation ?? 10,
|
||||||
onTap: () => _displayPinnedEventsDialog(
|
shadowColor: Theme.of(context).appBarTheme.shadowColor,
|
||||||
context,
|
child: InkWell(
|
||||||
pinnedEvents,
|
onTap: () => _displayPinnedEventsDialog(
|
||||||
),
|
context,
|
||||||
child: Row(
|
pinnedEvents,
|
||||||
children: [
|
),
|
||||||
IconButton(
|
child: Row(
|
||||||
splashRadius: 20,
|
children: [
|
||||||
iconSize: 20,
|
IconButton(
|
||||||
icon: const Icon(Icons.push_pin),
|
splashRadius: 20,
|
||||||
tooltip: L10n.of(context)!.unpin,
|
iconSize: 20,
|
||||||
onPressed: controller.room
|
icon: const Icon(Icons.push_pin),
|
||||||
?.canSendEvent(EventTypes.RoomPinnedEvents) ??
|
tooltip: L10n.of(context)!.unpin,
|
||||||
false
|
onPressed: controller.room
|
||||||
? () => controller.unpinEvent(event.eventId)
|
?.canSendEvent(EventTypes.RoomPinnedEvents) ??
|
||||||
: null,
|
false
|
||||||
),
|
? () => controller.unpinEvent(event.eventId)
|
||||||
Expanded(
|
: null,
|
||||||
child: Padding(
|
),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
Expanded(
|
||||||
child: LinkText(
|
child: Padding(
|
||||||
text: event.getLocalizedBody(
|
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||||
MatrixLocals(L10n.of(context)!),
|
child: LinkText(
|
||||||
withSenderNamePrefix: true,
|
text: event.getLocalizedBody(
|
||||||
hideReply: true,
|
MatrixLocals(L10n.of(context)!),
|
||||||
),
|
withSenderNamePrefix: true,
|
||||||
maxLines: 2,
|
hideReply: true,
|
||||||
textStyle: TextStyle(
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
fontSize: fontSize,
|
|
||||||
decoration: event.redacted
|
|
||||||
? TextDecoration.lineThrough
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
linkStyle: TextStyle(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyText1
|
|
||||||
?.color
|
|
||||||
?.withAlpha(150),
|
|
||||||
fontSize: fontSize,
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
),
|
|
||||||
onLinkTap: (url) =>
|
|
||||||
UrlLauncher(context, url).launchUrl(),
|
|
||||||
),
|
),
|
||||||
|
maxLines: 2,
|
||||||
|
textStyle: TextStyle(
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
fontSize: fontSize,
|
||||||
|
decoration: event.redacted
|
||||||
|
? TextDecoration.lineThrough
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
linkStyle: TextStyle(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyText1
|
||||||
|
?.color
|
||||||
|
?.withAlpha(150),
|
||||||
|
fontSize: fontSize,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
),
|
||||||
|
onLinkTap: (url) =>
|
||||||
|
UrlLauncher(context, url).launchUrl(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
} else if (snapshot.hasError) {
|
);
|
||||||
Logs().e('Error loading pinned events.', snapshot.error);
|
|
||||||
return ListTile(
|
|
||||||
tileColor: Theme.of(context).secondaryHeaderColor,
|
|
||||||
title: Text(L10n.of(context)!.pinnedEventsError));
|
|
||||||
} else {
|
|
||||||
return ListTile(
|
|
||||||
tileColor: Theme.of(context).secondaryHeaderColor,
|
|
||||||
title: const Center(
|
|
||||||
child: SizedBox.square(
|
|
||||||
dimension: 24,
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user