From c1a0cb3f8dc2d15ee56438c355b6ea9e36e55423 Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Thu, 30 Dec 2021 09:50:41 +0100 Subject: [PATCH 1/2] chore: Fix chat list regressions --- assets/l10n/intl_en.arb | 2 +- lib/pages/chat_list/chat_list_view.dart | 214 ++++++++++-------------- 2 files changed, 87 insertions(+), 129 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 28737638..de2e6b11 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2182,7 +2182,7 @@ "senderName": {} } }, - "startYourFirstChat": "Start your first chat right now! 🙂\n- Tap on the message button\n- Enter the username of a friend\n- Have fun chatting", + "startYourFirstChat": "Start your first chat right now! 🙂\n- Tap on 'New chat'\n- Scan the QR code of a friend\n- Have fun chatting", "@startYourFirstChat": { "type": "text", "placeholders": {} diff --git a/lib/pages/chat_list/chat_list_view.dart b/lib/pages/chat_list/chat_list_view.dart index 5d1a46b0..ff90d98d 100644 --- a/lib/pages/chat_list/chat_list_view.dart +++ b/lib/pages/chat_list/chat_list_view.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -284,10 +283,10 @@ class _ChatListViewBodyState extends State<_ChatListViewBody> { mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - const Icon( - Icons.maps_ugc_outlined, - size: 80, - color: Colors.grey, + Image.asset( + 'assets/private_chat_wallpaper.png', + width: 160, + height: 160, ), Center( child: Text( @@ -301,37 +300,90 @@ class _ChatListViewBodyState extends State<_ChatListViewBody> { ), ], ); - } - final displayStoriesHeader = widget.controller.activeSpaceId == null; - child = ListView.builder( - key: ValueKey(Matrix.of(context).client.userID.toString() + - widget.controller.activeSpaceId.toString()), - controller: widget.controller.scrollController, - itemCount: rooms.length + (displayStoriesHeader ? 1 : 0), - itemBuilder: (BuildContext context, int i) { - if (displayStoriesHeader) { - if (i == 0) { - return const StoriesHeader(); + } else { + final displayStoriesHeader = widget.controller.activeSpaceId == null; + child = ListView.builder( + key: ValueKey(Matrix.of(context).client.userID.toString() + + widget.controller.activeSpaceId.toString()), + controller: widget.controller.scrollController, + itemCount: rooms.length + (displayStoriesHeader ? 1 : 0), + itemBuilder: (BuildContext context, int i) { + if (displayStoriesHeader) { + if (i == 0) { + return const StoriesHeader(); + } + i--; } - i--; - } - return ChatListItem( - rooms[i], - selected: widget.controller.selectedRoomIds.contains(rooms[i].id), - onTap: widget.controller.selectMode == SelectMode.select - ? () => widget.controller.toggleSelection(rooms[i].id) - : null, - onLongPress: () => widget.controller.toggleSelection(rooms[i].id), - activeChat: widget.controller.activeChat == rooms[i].id, - ); - }, - ); + return ChatListItem( + rooms[i], + selected: widget.controller.selectedRoomIds.contains(rooms[i].id), + onTap: widget.controller.selectMode == SelectMode.select + ? () => widget.controller.toggleSelection(rooms[i].id) + : null, + onLongPress: () => widget.controller.toggleSelection(rooms[i].id), + activeChat: widget.controller.activeChat == rooms[i].id, + ); + }, + ); + } } else { - child = ListView( - key: const ValueKey(false), - children: List.filled( - 8, - const _DummyChat(), + const dummyChatCount = 8; + final titleColor = + Theme.of(context).textTheme.bodyText1.color.withAlpha(100); + final subtitleColor = + Theme.of(context).textTheme.bodyText1.color.withAlpha(50); + child = ListView.builder( + itemCount: dummyChatCount, + itemBuilder: (context, i) => Opacity( + opacity: (dummyChatCount - i) / dummyChatCount, + child: ListTile( + leading: CircleAvatar( + backgroundColor: titleColor, + child: CircularProgressIndicator( + strokeWidth: 1, + color: Theme.of(context).textTheme.bodyText1.color, + ), + ), + title: Row( + children: [ + Expanded( + child: Container( + height: 14, + decoration: BoxDecoration( + color: titleColor, + borderRadius: BorderRadius.circular(3), + ), + ), + ), + const SizedBox(width: 36), + Container( + height: 14, + width: 14, + decoration: BoxDecoration( + color: subtitleColor, + borderRadius: BorderRadius.circular(14), + ), + ), + const SizedBox(width: 12), + Container( + height: 14, + width: 14, + decoration: BoxDecoration( + color: subtitleColor, + borderRadius: BorderRadius.circular(14), + ), + ), + ], + ), + subtitle: Container( + decoration: BoxDecoration( + color: subtitleColor, + borderRadius: BorderRadius.circular(3), + ), + height: 12, + margin: const EdgeInsets.only(right: 22), + ), + ), ), ); } @@ -389,100 +441,6 @@ class _ChatListViewBodyState extends State<_ChatListViewBody> { } } -class _DummyChat extends StatefulWidget { - const _DummyChat({Key key}) : super(key: key); - - @override - State<_DummyChat> createState() => _DummyChatState(); -} - -class _DummyChatState extends State<_DummyChat> { - double opacity = Random().nextDouble(); - - Timer _timer; - - static const duration = Duration(seconds: 1); - - void _setRandomOpacity(_) { - if (mounted) { - setState(() => opacity = Random().nextDouble()); - } - } - - @override - void initState() { - WidgetsBinding.instance.addPostFrameCallback(_setRandomOpacity); - _timer ??= Timer.periodic(duration, _setRandomOpacity); - super.initState(); - } - - @override - void dispose() { - _timer?.cancel(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - final titleColor = - Theme.of(context).textTheme.bodyText1.color.withAlpha(100); - final subtitleColor = - Theme.of(context).textTheme.bodyText1.color.withAlpha(50); - return AnimatedOpacity( - opacity: opacity, - duration: duration, - child: ListTile( - leading: CircleAvatar( - backgroundColor: titleColor, - child: CircularProgressIndicator( - strokeWidth: 1, - color: Theme.of(context).textTheme.bodyText1.color, - ), - ), - title: Row( - children: [ - Expanded( - child: Container( - height: 14, - decoration: BoxDecoration( - color: titleColor, - borderRadius: BorderRadius.circular(3), - ), - ), - ), - const SizedBox(width: 36), - Container( - height: 14, - width: 14, - decoration: BoxDecoration( - color: subtitleColor, - borderRadius: BorderRadius.circular(14), - ), - ), - const SizedBox(width: 12), - Container( - height: 14, - width: 14, - decoration: BoxDecoration( - color: subtitleColor, - borderRadius: BorderRadius.circular(14), - ), - ), - ], - ), - subtitle: Container( - decoration: BoxDecoration( - color: subtitleColor, - borderRadius: BorderRadius.circular(3), - ), - height: 12, - margin: const EdgeInsets.only(right: 22), - ), - ), - ); - } -} - enum ChatListPopupMenuItemActions { createGroup, createSpace, From 7024af3a16fbf67bb03b248455980c3e08a1e7ca Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Thu, 30 Dec 2021 09:53:55 +0100 Subject: [PATCH 2/2] chore: Delete story only if can redact --- lib/pages/search/search.dart | 2 +- lib/pages/story/story_view.dart | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pages/search/search.dart b/lib/pages/search/search.dart index d94c5d9b..2e5571fc 100644 --- a/lib/pages/search/search.dart +++ b/lib/pages/search/search.dart @@ -112,8 +112,8 @@ class SearchController extends State { @override void initState() { super.initState(); - controller.text = VRouter.of(context).queryParameters['query'] ?? ''; WidgetsBinding.instance?.addPostFrameCallback((_) async { + controller.text = VRouter.of(context).queryParameters['query'] ?? ''; final server = await Store().getItem(_serverStoreNamespace) as String?; if (server?.isNotEmpty ?? false) { this.server = server; diff --git a/lib/pages/story/story_view.dart b/lib/pages/story/story_view.dart index eceb1287..3131d6e8 100644 --- a/lib/pages/story/story_view.dart +++ b/lib/pages/story/story_view.dart @@ -87,10 +87,11 @@ class StoryView extends StatelessWidget { child: PopupMenuButton( onSelected: controller.onPopupStoryAction, itemBuilder: (context) => [ - PopupMenuItem( - value: PopupStoryAction.delete, - child: Text(L10n.of(context)!.delete), - ), + if (controller.currentEvent?.canRedact ?? false) + PopupMenuItem( + value: PopupStoryAction.delete, + child: Text(L10n.of(context)!.delete), + ), PopupMenuItem( value: PopupStoryAction.report, child: Text(L10n.of(context)!.reportMessage), @@ -336,6 +337,10 @@ class StoryView extends StatelessWidget { child: SafeArea( child: Center( child: OutlinedButton.icon( + style: OutlinedButton.styleFrom( + backgroundColor: + Theme.of(context).colorScheme.surface, + ), onPressed: controller.displaySeenByUsers, icon: const Icon( Icons.visibility_outlined,