💄 Optimized post create popup
This commit is contained in:
parent
6d92a16a62
commit
02c28533db
@ -34,7 +34,7 @@ class PostProvider extends GetConnect {
|
|||||||
'offset=$page',
|
'offset=$page',
|
||||||
];
|
];
|
||||||
final client = auth.configureClient('interactive');
|
final client = auth.configureClient('interactive');
|
||||||
final resp = await client.get('/drafts?${queries.join('&')}');
|
final resp = await client.get('/posts/drafts?${queries.join('&')}');
|
||||||
if (resp.statusCode != 200) {
|
if (resp.statusCode != 200) {
|
||||||
throw Exception(resp.body);
|
throw Exception(resp.body);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
|||||||
import 'package:solian/models/pagination.dart';
|
import 'package:solian/models/pagination.dart';
|
||||||
import 'package:solian/models/post.dart';
|
import 'package:solian/models/post.dart';
|
||||||
import 'package:solian/providers/content/posts.dart';
|
import 'package:solian/providers/content/posts.dart';
|
||||||
import 'package:solian/screens/home.dart';
|
|
||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
import 'package:solian/widgets/app_bar_leading.dart';
|
import 'package:solian/widgets/app_bar_leading.dart';
|
||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
@ -64,10 +63,6 @@ class _DraftBoxScreenState extends State<DraftBoxScreen> {
|
|||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
actions: [
|
actions: [
|
||||||
FeedCreationButton(
|
|
||||||
hideDraftBox: true,
|
|
||||||
onCreated: () {},
|
|
||||||
),
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
|
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
|
||||||
),
|
),
|
||||||
|
@ -52,10 +52,21 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Material(
|
||||||
body: Material(
|
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
child: RefreshIndicator(
|
child: Scaffold(
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
child: const Icon(Icons.add),
|
||||||
|
onPressed: () {
|
||||||
|
showModalBottomSheet(
|
||||||
|
useRootNavigator: true,
|
||||||
|
isScrollControlled: true,
|
||||||
|
context: context,
|
||||||
|
builder: (context) => const PostCreatePopup(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
body: RefreshIndicator(
|
||||||
onRefresh: () => Future.sync(() => _pagingController.refresh()),
|
onRefresh: () => Future.sync(() => _pagingController.refresh()),
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
@ -68,11 +79,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
actions: [
|
actions: [
|
||||||
const BackgroundStateWidget(),
|
const BackgroundStateWidget(),
|
||||||
const NotificationButton(),
|
const NotificationButton(),
|
||||||
FeedCreationButton(
|
|
||||||
onCreated: () {
|
|
||||||
_pagingController.refresh();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
|
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
|
||||||
),
|
),
|
||||||
@ -93,11 +99,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FeedCreationButton extends StatelessWidget {
|
class PostCreatePopup extends StatelessWidget {
|
||||||
final bool hideDraftBox;
|
final bool hideDraftBox;
|
||||||
final Function? onCreated;
|
final Function? onCreated;
|
||||||
|
|
||||||
const FeedCreationButton({
|
const PostCreatePopup({
|
||||||
super.key,
|
super.key,
|
||||||
this.hideDraftBox = false,
|
this.hideDraftBox = false,
|
||||||
this.onCreated,
|
this.onCreated,
|
||||||
@ -111,35 +117,62 @@ class FeedCreationButton extends StatelessWidget {
|
|||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
return PopupMenuButton(
|
final List<dynamic> actionList = [
|
||||||
|
(
|
||||||
icon: const Icon(Icons.edit_square),
|
icon: const Icon(Icons.edit_square),
|
||||||
itemBuilder: (BuildContext context) => [
|
label: 'postEditor'.tr,
|
||||||
PopupMenuItem(
|
|
||||||
child: ListTile(
|
|
||||||
title: Text('postEditor'.tr),
|
|
||||||
leading: const Icon(Icons.article),
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
),
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
AppRouter.instance.pushNamed('postEditor').then((val) {
|
AppRouter.instance.pushNamed('postEditor').then((val) {
|
||||||
if (val != null && onCreated != null) {
|
if (val != null && onCreated != null) onCreated!();
|
||||||
onCreated!();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (!hideDraftBox)
|
(
|
||||||
PopupMenuItem(
|
icon: const Icon(Icons.drafts),
|
||||||
child: ListTile(
|
label: 'draftBoxOpen'.tr,
|
||||||
title: Text('draftBoxOpen'.tr),
|
|
||||||
leading: const Icon(Icons.drafts),
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
),
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
AppRouter.instance.pushNamed('draftBox');
|
AppRouter.instance.pushNamed('draftBox');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.35,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'postNew'.tr,
|
||||||
|
style: Theme.of(context).textTheme.headlineSmall,
|
||||||
|
).paddingOnly(left: 24, right: 24, top: 32, bottom: 16),
|
||||||
|
Expanded(
|
||||||
|
child: GridView.count(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
crossAxisCount: 3,
|
||||||
|
children: actionList
|
||||||
|
.map((x) => Card(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius:
|
||||||
|
const BorderRadius.all(Radius.circular(8)),
|
||||||
|
onTap: x.onTap,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
x.icon,
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(x.label),
|
||||||
],
|
],
|
||||||
|
).paddingAll(18),
|
||||||
|
),
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
).paddingSymmetric(horizontal: 20),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user