mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 23:09:35 +01:00
Merge branch 'krille/share-stories' into 'main'
feat: Share to story See merge request famedly/fluffychat!644
This commit is contained in:
commit
5f8001ec35
@ -2667,5 +2667,6 @@
|
|||||||
"publish": "Publish",
|
"publish": "Publish",
|
||||||
"whoCanSeeMyStories": "Who can see my stories?",
|
"whoCanSeeMyStories": "Who can see my stories?",
|
||||||
"unsubscribeStories": "Unsubscribe stories",
|
"unsubscribeStories": "Unsubscribe stories",
|
||||||
"thisUserHasNotPostedAnythingYet": "This user has not posted anything in their story yet"
|
"thisUserHasNotPostedAnythingYet": "This user has not posted anything in their story yet",
|
||||||
|
"yourStory": "Your story"
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,41 @@ class AddStoryController extends State<AddStoryPage> {
|
|||||||
final text = Matrix.of(context).client.userID!;
|
final text = Matrix.of(context).client.userID!;
|
||||||
backgroundColor = text.color;
|
backgroundColor = text.color;
|
||||||
backgroundColorDark = text.darkColor;
|
backgroundColorDark = text.darkColor;
|
||||||
|
|
||||||
|
final shareContent = Matrix.of(context).shareContent;
|
||||||
|
// ignore: unnecessary_null_comparison
|
||||||
|
if (shareContent != null) {
|
||||||
|
image = shareContent.tryGet<MatrixFile>('file');
|
||||||
|
controller.text = shareContent.tryGet<String>('body') ?? '';
|
||||||
|
if (shareContent.tryGet<String>('msgtype') == MessageTypes.Image) {
|
||||||
|
Event(
|
||||||
|
content: shareContent,
|
||||||
|
type: EventTypes.Message,
|
||||||
|
room: Room(id: '!tmproom', client: Matrix.of(context).client),
|
||||||
|
eventId: 'tmpevent',
|
||||||
|
senderId: '@tmpsender:example',
|
||||||
|
originServerTs: DateTime.now(),
|
||||||
|
).downloadAndDecryptAttachment().then((file) {
|
||||||
|
setState(() {
|
||||||
|
image = file;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (shareContent.tryGet<String>('msgtype') == MessageTypes.Video) {
|
||||||
|
Event(
|
||||||
|
content: shareContent,
|
||||||
|
type: EventTypes.Message,
|
||||||
|
room: Room(id: '!tmproom', client: Matrix.of(context).client),
|
||||||
|
eventId: 'tmpevent',
|
||||||
|
senderId: '@tmpsender:example',
|
||||||
|
originServerTs: DateTime.now(),
|
||||||
|
).downloadAndDecryptAttachment().then((file) {
|
||||||
|
setState(() {
|
||||||
|
video = file;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Matrix.of(context).shareContent = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -308,7 +308,7 @@ class _ChatListViewBodyState extends State<_ChatListViewBody> {
|
|||||||
controller: widget.controller.scrollController,
|
controller: widget.controller.scrollController,
|
||||||
itemCount: rooms.length + 1,
|
itemCount: rooms.length + 1,
|
||||||
itemBuilder: (BuildContext context, int i) {
|
itemBuilder: (BuildContext context, int i) {
|
||||||
if (i == 0) {
|
if (i == 0 && widget.controller.activeSpaceId == null) {
|
||||||
return const StoriesHeader();
|
return const StoriesHeader();
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
@ -332,6 +332,10 @@ class _ChatListViewBodyState extends State<_ChatListViewBody> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
child = Material(
|
||||||
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
return PageTransitionSwitcher(
|
return PageTransitionSwitcher(
|
||||||
reverse: reversed,
|
reverse: reversed,
|
||||||
transitionBuilder: (
|
transitionBuilder: (
|
||||||
|
@ -13,7 +13,11 @@ import 'package:fluffychat/utils/matrix_sdk_extensions.dart/client_stories_exten
|
|||||||
import 'package:fluffychat/widgets/avatar.dart';
|
import 'package:fluffychat/widgets/avatar.dart';
|
||||||
import 'package:fluffychat/widgets/matrix.dart';
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
|
|
||||||
enum ContextualRoomAction { mute, unmute, leave }
|
enum ContextualRoomAction {
|
||||||
|
mute,
|
||||||
|
unmute,
|
||||||
|
leave,
|
||||||
|
}
|
||||||
|
|
||||||
class StoriesHeader extends StatelessWidget {
|
class StoriesHeader extends StatelessWidget {
|
||||||
const StoriesHeader({Key? key}) : super(key: key);
|
const StoriesHeader({Key? key}) : super(key: key);
|
||||||
@ -82,7 +86,8 @@ class StoriesHeader extends StatelessWidget {
|
|||||||
if (client.storiesRooms.isEmpty && client.contacts.isEmpty) {
|
if (client.storiesRooms.isEmpty && client.contacts.isEmpty) {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
if (client.storiesRooms.isEmpty) {
|
if (client.storiesRooms.isEmpty ||
|
||||||
|
Matrix.of(context).shareContent != null) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
radius: Avatar.defaultSize / 2,
|
radius: Avatar.defaultSize / 2,
|
||||||
@ -95,13 +100,13 @@ class StoriesHeader extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 82,
|
height: 98,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 2),
|
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
children: [
|
children: [
|
||||||
_StoryButton(
|
_StoryButton(
|
||||||
label: 'Add to story',
|
label: L10n.of(context)!.yourStory,
|
||||||
onPressed: () => _addToStoryAction(context),
|
onPressed: () => _addToStoryAction(context),
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
@ -116,6 +121,7 @@ class StoriesHeader extends StatelessWidget {
|
|||||||
.sender
|
.sender
|
||||||
.avatarUrl,
|
.avatarUrl,
|
||||||
name: room.creatorDisplayname,
|
name: room.creatorDisplayname,
|
||||||
|
size: 100,
|
||||||
),
|
),
|
||||||
unread: room.notificationCount > 0 ||
|
unread: room.notificationCount > 0 ||
|
||||||
room.membership == Membership.invite,
|
room.membership == Membership.invite,
|
||||||
@ -168,13 +174,13 @@ class _StoryButton extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 74,
|
width: 78,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||||
onTap: onPressed,
|
onTap: onPressed,
|
||||||
onLongPress: onLongPressed,
|
onLongPress: onLongPressed,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 2),
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
@ -192,14 +198,22 @@ class _StoryButton extends StatelessWidget {
|
|||||||
end: Alignment.bottomRight,
|
end: Alignment.bottomRight,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
color: unread ? null : Theme.of(context).colorScheme.surface,
|
color: unread ? null : Theme.of(context).dividerColor,
|
||||||
borderRadius: BorderRadius.circular(Avatar.defaultSize),
|
borderRadius: BorderRadius.circular(Avatar.defaultSize),
|
||||||
),
|
),
|
||||||
child: CircleAvatar(
|
child: Material(
|
||||||
radius: Avatar.defaultSize / 2,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
borderRadius: BorderRadius.circular(Avatar.defaultSize),
|
||||||
foregroundColor: Theme.of(context).textTheme.bodyText1?.color,
|
child: Padding(
|
||||||
child: child,
|
padding: const EdgeInsets.all(2.0),
|
||||||
|
child: CircleAvatar(
|
||||||
|
radius: 30,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
|
foregroundColor:
|
||||||
|
Theme.of(context).textTheme.bodyText1?.color,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
@ -207,9 +221,9 @@ class _StoryButton extends StatelessWidget {
|
|||||||
label,
|
label,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: unread ? FontWeight.bold : null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user