chore: Story design follow up
This commit is contained in:
parent
8331685f09
commit
4bff64c86e
3 changed files with 165 additions and 169 deletions
|
|
@ -14,6 +14,7 @@ import 'package:vrouter/vrouter.dart';
|
|||
import 'package:fluffychat/pages/add_story/add_story_view.dart';
|
||||
import 'package:fluffychat/pages/add_story/invite_story_page.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart';
|
||||
import 'package:fluffychat/utils/resize_image.dart';
|
||||
import 'package:fluffychat/utils/room_send_file_extension.dart';
|
||||
import 'package:fluffychat/utils/string_color.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
|
@ -81,6 +82,7 @@ class AddStoryController extends State<AddStoryPage> {
|
|||
}
|
||||
|
||||
void postStory() async {
|
||||
if (video == null && image == null && controller.text.isEmpty) return;
|
||||
final client = Matrix.of(context).client;
|
||||
var storiesRoom = await client.getStoriesRoom(context);
|
||||
|
||||
|
|
@ -106,18 +108,20 @@ class AddStoryController extends State<AddStoryPage> {
|
|||
context: context,
|
||||
future: () async {
|
||||
if (storiesRoom == null) throw ('Stories room is null');
|
||||
final video = this.video;
|
||||
var video = this.video?.detectFileType;
|
||||
if (video != null) {
|
||||
video = await video.resizeVideo();
|
||||
await storiesRoom.sendFileEventWithThumbnail(
|
||||
video.detectFileType,
|
||||
video,
|
||||
extraContent: {'body': controller.text},
|
||||
);
|
||||
return;
|
||||
}
|
||||
final image = this.image;
|
||||
var image = this.image?.detectFileType;
|
||||
if (image != null) {
|
||||
image = await image.resizeImage();
|
||||
await storiesRoom.sendFileEventWithThumbnail(
|
||||
image.detectFileType,
|
||||
image,
|
||||
extraContent: {'body': controller.text},
|
||||
);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -59,13 +59,19 @@ class AddStoryView extends StatelessWidget {
|
|||
body: Stack(
|
||||
children: [
|
||||
if (video != null)
|
||||
FutureBuilder(
|
||||
future: video.initialize().then((_) => video.play()),
|
||||
builder: (_, __) => Center(child: VideoPlayer(video)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 80.0),
|
||||
child: FutureBuilder(
|
||||
future: video.initialize().then((_) => video.play()),
|
||||
builder: (_, __) => Center(child: VideoPlayer(video)),
|
||||
),
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(seconds: 2),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0,
|
||||
vertical: 80.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
image: controller.image == null
|
||||
? null
|
||||
|
|
@ -96,7 +102,9 @@ class AddStoryView extends StatelessWidget {
|
|||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.white,
|
||||
backgroundColor: !controller.hasMedia ? null : Colors.black,
|
||||
backgroundColor: !controller.hasMedia
|
||||
? null
|
||||
: Colors.black.withOpacity(0.5),
|
||||
),
|
||||
onEditingComplete: controller.updateColors,
|
||||
decoration: InputDecoration(
|
||||
|
|
@ -117,16 +125,13 @@ class AddStoryView extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton:
|
||||
controller.controller.text.isEmpty && !controller.hasMedia
|
||||
? null
|
||||
: FloatingActionButton.extended(
|
||||
onPressed: controller.postStory,
|
||||
label: Text(L10n.of(context)!.publish),
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||
icon: const Icon(Icons.send_rounded),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: controller.postStory,
|
||||
label: Text(L10n.of(context)!.publish),
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||
icon: const Icon(Icons.send_rounded),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue