Merge branch 'krille/redesign-empty-stories' into 'main'

design: Use IconButton instead of listTile for first story

See merge request famedly/fluffychat!710
This commit is contained in:
Krille Fear 2022-02-03 08:11:58 +00:00
commit c67459dbc2
2 changed files with 61 additions and 50 deletions

View File

@ -14,6 +14,7 @@ import 'package:fluffychat/pages/chat_list/chat_list_item.dart';
import 'package:fluffychat/pages/chat_list/client_chooser_button.dart'; import 'package:fluffychat/pages/chat_list/client_chooser_button.dart';
import 'package:fluffychat/pages/chat_list/spaces_bottom_bar.dart'; import 'package:fluffychat/pages/chat_list/spaces_bottom_bar.dart';
import 'package:fluffychat/pages/chat_list/stories_header.dart'; import 'package:fluffychat/pages/chat_list/stories_header.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/client_stories_extension.dart';
import 'package:fluffychat/widgets/connection_status_header.dart'; import 'package:fluffychat/widgets/connection_status_header.dart';
import '../../utils/stream_extension.dart'; import '../../utils/stream_extension.dart';
import '../../widgets/matrix.dart'; import '../../widgets/matrix.dart';
@ -99,6 +100,14 @@ class ChatListView extends StatelessWidget {
onPressed: () => onPressed: () =>
VRouter.of(context).to('/search'), VRouter.of(context).to('/search'),
), ),
if (selectMode == SelectMode.normal &&
Matrix.of(context).client.storiesRooms.isEmpty)
IconButton(
icon: const Icon(Icons.camera_alt_outlined),
tooltip: L10n.of(context)!.addToStory,
onPressed: () =>
VRouter.of(context).to('/stories/create'),
),
PopupMenuButton<PopupMenuAction>( PopupMenuButton<PopupMenuAction>(
onSelected: controller.onPopupMenuSelect, onSelected: controller.onPopupMenuSelect,
itemBuilder: (_) => [ itemBuilder: (_) => [

View File

@ -87,61 +87,63 @@ class StoriesHeader extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final client = Matrix.of(context).client; final client = Matrix.of(context).client;
return StreamBuilder<Object>( return StreamBuilder(
stream: client.onSync.stream stream: Matrix.of(context).onShareContentChanged.stream,
.where((syncUpdate) => syncUpdate.hasRoomUpdate), builder: (context, _) => StreamBuilder<Object>(
builder: (context, snapshot) { stream: client.onSync.stream
if (client.storiesRooms.isEmpty && client.contacts.isEmpty) { .where((syncUpdate) => syncUpdate.hasRoomUpdate),
return Container(); builder: (context, snapshot) {
} if (Matrix.of(context).shareContent != null) {
if (client.storiesRooms.isEmpty || return ListTile(
Matrix.of(context).shareContent != null) { leading: CircleAvatar(
return ListTile( radius: Avatar.defaultSize / 2,
leading: CircleAvatar( backgroundColor: Theme.of(context).colorScheme.surface,
radius: Avatar.defaultSize / 2, foregroundColor: Theme.of(context).textTheme.bodyText1?.color,
backgroundColor: Theme.of(context).colorScheme.surface,
foregroundColor: Theme.of(context).textTheme.bodyText1?.color,
child: const Icon(Icons.add),
),
title: Text(L10n.of(context)!.addToStory),
onTap: () => _addToStoryAction(context),
);
}
return SizedBox(
height: 98,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 2),
scrollDirection: Axis.horizontal,
children: [
_StoryButton(
label: L10n.of(context)!.yourStory,
onPressed: () => _addToStoryAction(context),
child: const Icon(Icons.add), child: const Icon(Icons.add),
), ),
...client.storiesRooms.map( title: Text(L10n.of(context)!.addToStory),
(room) => Opacity( onTap: () => _addToStoryAction(context),
opacity: room.hasPosts ? 1 : 0.5, );
child: _StoryButton( }
label: room.creatorDisplayname, if (client.storiesRooms.isEmpty) {
child: Avatar( return Container();
mxContent: room }
.getState(EventTypes.RoomCreate)! return SizedBox(
.sender height: 98,
.avatarUrl, child: ListView(
name: room.creatorDisplayname, padding: const EdgeInsets.symmetric(horizontal: 2),
size: 100, scrollDirection: Axis.horizontal,
children: [
_StoryButton(
label: L10n.of(context)!.yourStory,
onPressed: () => _addToStoryAction(context),
child: const Icon(Icons.add),
),
...client.storiesRooms.map(
(room) => Opacity(
opacity: room.hasPosts ? 1 : 0.5,
child: _StoryButton(
label: room.creatorDisplayname,
child: Avatar(
mxContent: room
.getState(EventTypes.RoomCreate)!
.sender
.avatarUrl,
name: room.creatorDisplayname,
size: 100,
),
unread: room.notificationCount > 0 ||
room.membership == Membership.invite,
onPressed: () => _goToStoryAction(context, room.id),
onLongPressed: () => _contextualActions(context, room),
), ),
unread: room.notificationCount > 0 ||
room.membership == Membership.invite,
onPressed: () => _goToStoryAction(context, room.id),
onLongPressed: () => _contextualActions(context, room),
), ),
), ),
), ],
], ),
), );
); }),
}); );
} }
} }