mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 09:35:12 +00:00
chore: Follow up status feature
This commit is contained in:
parent
376d59889b
commit
fa543e93b8
3 changed files with 21 additions and 8 deletions
|
@ -153,6 +153,7 @@ class ChatListViewBody extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
if (!controller.isSearchMode)
|
||||||
StatusMessageList(
|
StatusMessageList(
|
||||||
onStatusEdit: controller.setStatus,
|
onStatusEdit: controller.setStatus,
|
||||||
),
|
),
|
||||||
|
|
|
@ -18,7 +18,7 @@ class StatusMessageList extends StatelessWidget {
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
static const double height = 108;
|
static const double height = 116;
|
||||||
|
|
||||||
void _onStatusTab(BuildContext context, Profile profile) {
|
void _onStatusTab(BuildContext context, Profile profile) {
|
||||||
final client = Matrix.of(context).client;
|
final client = Matrix.of(context).client;
|
||||||
|
@ -37,6 +37,8 @@ class StatusMessageList extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final client = Matrix.of(context).client;
|
final client = Matrix.of(context).client;
|
||||||
|
final interestingPresences = client.interestingPresences;
|
||||||
|
|
||||||
return StreamBuilder(
|
return StreamBuilder(
|
||||||
stream: client.onSync.stream.rateLimit(const Duration(seconds: 3)),
|
stream: client.onSync.stream.rateLimit(const Duration(seconds: 3)),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
|
@ -44,6 +46,10 @@ class StatusMessageList extends StatelessWidget {
|
||||||
duration: FluffyThemes.animationDuration,
|
duration: FluffyThemes.animationDuration,
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
child: FutureBuilder(
|
child: FutureBuilder(
|
||||||
|
initialData: interestingPresences
|
||||||
|
// ignore: deprecated_member_use
|
||||||
|
.map((userId) => client.presences[userId])
|
||||||
|
.whereType<CachedPresence>(),
|
||||||
future: Future.wait(
|
future: Future.wait(
|
||||||
client.interestingPresences
|
client.interestingPresences
|
||||||
.map((userId) => client.fetchCurrentPresence(userId)),
|
.map((userId) => client.fetchCurrentPresence(userId)),
|
||||||
|
@ -69,7 +75,7 @@ class StatusMessageList extends StatelessWidget {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: StatusMessageList.height,
|
height: StatusMessageList.height,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
padding: const EdgeInsets.all(8),
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
itemCount: presences.length,
|
itemCount: presences.length,
|
||||||
itemBuilder: (context, i) => PresenceAvatar(
|
itemBuilder: (context, i) => PresenceAvatar(
|
||||||
|
@ -101,7 +107,7 @@ class PresenceAvatar extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final avatarSize = height - 16 - 16;
|
final avatarSize = height - 16 - 16 - 8;
|
||||||
final client = Matrix.of(context).client;
|
final client = Matrix.of(context).client;
|
||||||
return FutureBuilder<Profile>(
|
return FutureBuilder<Profile>(
|
||||||
future: client.getProfileFromUserId(presence.userid),
|
future: client.getProfileFromUserId(presence.userid),
|
||||||
|
@ -162,6 +168,9 @@ class PresenceAvatar extends StatelessWidget {
|
||||||
profile ??
|
profile ??
|
||||||
Profile(userId: presence.userid),
|
Profile(userId: presence.userid),
|
||||||
),
|
),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
Icons.add_outlined,
|
Icons.add_outlined,
|
||||||
size: 16,
|
size: 16,
|
||||||
|
|
|
@ -419,9 +419,12 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||||
Logs().v('AppLifecycleState = $state');
|
Logs().v('AppLifecycleState = $state');
|
||||||
final foreground = state != AppLifecycleState.detached &&
|
final foreground = state != AppLifecycleState.detached &&
|
||||||
state != AppLifecycleState.paused;
|
state != AppLifecycleState.paused;
|
||||||
|
client.syncPresence = foreground ? null : PresenceType.unavailable;
|
||||||
|
if (PlatformInfos.isMobile) {
|
||||||
client.backgroundSync = foreground;
|
client.backgroundSync = foreground;
|
||||||
client.requestHistoryOnLimitedTimeline = !foreground;
|
client.requestHistoryOnLimitedTimeline = !foreground;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void initSettings() {
|
void initSettings() {
|
||||||
final path = store.getString(SettingKeys.wallpaper);
|
final path = store.getString(SettingKeys.wallpaper);
|
||||||
|
|
Loading…
Reference in a new issue