Post details

💄 Somewhere optimization
This commit is contained in:
2024-03-24 22:57:12 +08:00
parent 217c20164f
commit 91d238bc2f
11 changed files with 139 additions and 22 deletions

View File

@ -83,7 +83,7 @@ class _ExploreScreenState extends State<ExploreScreen> {
return FloatingActionButton(
child: const Icon(Icons.edit),
onPressed: () {
router.push("/post/moments").then((value) {
router.push("/post/new/moments").then((value) {
if (value == true) paginationController.refresh();
});
},

View File

@ -0,0 +1,64 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:solaragent/models/feed.dart';
import 'package:solaragent/widgets/feed.dart';
class PostScreen extends StatefulWidget {
final Client client = Client();
final String modelType;
final String alias;
PostScreen({super.key, required this.modelType, required this.alias});
@override
State<PostScreen> createState() => _PostScreenState();
}
class _PostScreenState extends State<PostScreen> {
Future<Feed?> pullPost(BuildContext context) async {
var uri = Uri.parse(
"https://co.solsynth.dev/api/p/${widget.modelType}s/${widget.alias}",
);
var res = await widget.client.get(uri);
if (res.statusCode != 200) {
var err = utf8.decode(res.bodyBytes);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Something went wrong... $err")),
);
return null;
} else {
return Feed.fromJson(jsonDecode(utf8.decode(res.bodyBytes)));
}
}
Widget buildItem(BuildContext context, Feed item) {
return FeedItem(
item: item,
brief: false,
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Post")),
body: FutureBuilder(
future: pullPost(context),
builder: (context, snapshot) {
if (snapshot.hasData && snapshot.data != null) {
return SingleChildScrollView(
child: buildItem(context, snapshot.data!),
);
} else {
return const Center(
child: CircularProgressIndicator(),
);
}
},
),
);
}
}

View File

@ -132,7 +132,9 @@ class _CommentEditorScreenState extends State<CommentEditorScreen> {
child: const Text('OPEN'),
onPressed: () async {
await launchUrl(
Uri.parse("https://co.solsynth.dev"));
Uri.parse("https://co.solsynth.dev"),
mode: LaunchMode.externalApplication,
);
},
),
TextButton(

View File

@ -154,7 +154,9 @@ class _MomentEditorScreenState extends State<MomentEditorScreen> {
child: const Text('OPEN'),
onPressed: () async {
await launchUrl(
Uri.parse("https://co.solsynth.dev"));
Uri.parse("https://co.solsynth.dev"),
mode: LaunchMode.externalApplication,
);
},
),
TextButton(