✨ Post new fab
This commit is contained in:
parent
fa142a5f89
commit
05425da913
@ -64,5 +64,7 @@
|
|||||||
"accountProfileEditApplied": "Profile modification applied.",
|
"accountProfileEditApplied": "Profile modification applied.",
|
||||||
"publishersNew": "New Publisher",
|
"publishersNew": "New Publisher",
|
||||||
"publisherNewSubtitle": "Create a new publisher identity.",
|
"publisherNewSubtitle": "Create a new publisher identity.",
|
||||||
"publisherSyncWithAccount": "Sync with account"
|
"publisherSyncWithAccount": "Sync with account",
|
||||||
|
"writePostTypeStory": "Post a story",
|
||||||
|
"writePostTypeArticle": "Write an article"
|
||||||
}
|
}
|
||||||
|
@ -64,5 +64,7 @@
|
|||||||
"accountProfileEditApplied": "个人资料修改已被应用。",
|
"accountProfileEditApplied": "个人资料修改已被应用。",
|
||||||
"publishersNew": "新发布者",
|
"publishersNew": "新发布者",
|
||||||
"publisherNewSubtitle": "创建一个新的公共身份。",
|
"publisherNewSubtitle": "创建一个新的公共身份。",
|
||||||
"publisherSyncWithAccount": "同步账户信息"
|
"publisherSyncWithAccount": "同步账户信息",
|
||||||
|
"writePostTypeStory": "发动态",
|
||||||
|
"writePostTypeArticle": "写文章"
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import 'package:surface/screens/auth/login.dart';
|
|||||||
import 'package:surface/screens/auth/register.dart';
|
import 'package:surface/screens/auth/register.dart';
|
||||||
import 'package:surface/screens/explore.dart';
|
import 'package:surface/screens/explore.dart';
|
||||||
import 'package:surface/screens/home.dart';
|
import 'package:surface/screens/home.dart';
|
||||||
|
import 'package:surface/screens/post/post_editor.dart';
|
||||||
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
||||||
|
|
||||||
final appRouter = GoRouter(
|
final appRouter = GoRouter(
|
||||||
@ -35,6 +36,18 @@ final appRouter = GoRouter(
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
ShellRoute(
|
||||||
|
builder: (context, state, child) => AppScaffold(
|
||||||
|
body: child,
|
||||||
|
),
|
||||||
|
routes: [
|
||||||
|
GoRoute(
|
||||||
|
path: '/post/write/:mode',
|
||||||
|
name: 'postEditor',
|
||||||
|
builder: (context, state) => const PostEditorScreen(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
ShellRoute(
|
ShellRoute(
|
||||||
builder: (context, state, child) => AppScaffold(
|
builder: (context, state, child) => AppScaffold(
|
||||||
body: child,
|
body: child,
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_expandable_fab/flutter_expandable_fab.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:surface/providers/sn_attachment.dart';
|
import 'package:surface/providers/sn_attachment.dart';
|
||||||
import 'package:surface/providers/sn_network.dart';
|
import 'package:surface/providers/sn_network.dart';
|
||||||
@ -16,6 +20,8 @@ class ExploreScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ExploreScreenState extends State<ExploreScreen> {
|
class _ExploreScreenState extends State<ExploreScreen> {
|
||||||
|
final _fabKey = GlobalKey<ExpandableFabState>();
|
||||||
|
|
||||||
bool _isBusy = true;
|
bool _isBusy = true;
|
||||||
|
|
||||||
final List<SnPost> _posts = List.empty(growable: true);
|
final List<SnPost> _posts = List.empty(growable: true);
|
||||||
@ -72,6 +78,78 @@ class _ExploreScreenState extends State<ExploreScreen> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text('screenExplore').tr(),
|
title: Text('screenExplore').tr(),
|
||||||
),
|
),
|
||||||
|
floatingActionButtonLocation: ExpandableFab.location,
|
||||||
|
floatingActionButton: ExpandableFab(
|
||||||
|
key: _fabKey,
|
||||||
|
distance: 75,
|
||||||
|
type: ExpandableFabType.up,
|
||||||
|
childrenAnimation: ExpandableFabAnimation.none,
|
||||||
|
overlayStyle: ExpandableFabOverlayStyle(blur: 10),
|
||||||
|
openButtonBuilder: RotateFloatingActionButtonBuilder(
|
||||||
|
child: const Icon(Symbols.add, size: 28),
|
||||||
|
fabSize: ExpandableFabSize.regular,
|
||||||
|
foregroundColor:
|
||||||
|
Theme.of(context).floatingActionButtonTheme.foregroundColor,
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).floatingActionButtonTheme.backgroundColor,
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
),
|
||||||
|
closeButtonBuilder: DefaultFloatingActionButtonBuilder(
|
||||||
|
child: const Icon(Symbols.close, size: 28),
|
||||||
|
fabSize: ExpandableFabSize.regular,
|
||||||
|
foregroundColor:
|
||||||
|
Theme.of(context).floatingActionButtonTheme.foregroundColor,
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).floatingActionButtonTheme.backgroundColor,
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text('writePostTypeStory').tr(),
|
||||||
|
const Gap(20),
|
||||||
|
FloatingActionButton(
|
||||||
|
heroTag: null,
|
||||||
|
tooltip: 'writePostTypeStory'.tr(),
|
||||||
|
onPressed: () {
|
||||||
|
GoRouter.of(context).pushNamed('postEditor', pathParameters: {
|
||||||
|
'mode': 'story',
|
||||||
|
}).then((value) {
|
||||||
|
if (value == true) {
|
||||||
|
_posts.clear();
|
||||||
|
_fetchPosts();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_fabKey.currentState!.toggle();
|
||||||
|
},
|
||||||
|
child: const Icon(Symbols.post_rounded),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text('writePostTypeArticle').tr(),
|
||||||
|
const Gap(20),
|
||||||
|
FloatingActionButton(
|
||||||
|
heroTag: null,
|
||||||
|
tooltip: 'writePostTypeArticle'.tr(),
|
||||||
|
onPressed: () {
|
||||||
|
GoRouter.of(context).pushNamed('postEditor', pathParameters: {
|
||||||
|
'mode': 'article',
|
||||||
|
}).then((value) {
|
||||||
|
if (value == true) {
|
||||||
|
_posts.clear();
|
||||||
|
_fetchPosts();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_fabKey.currentState!.toggle();
|
||||||
|
},
|
||||||
|
child: const Icon(Symbols.news),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
body: InfiniteList(
|
body: InfiniteList(
|
||||||
itemCount: _posts.length,
|
itemCount: _posts.length,
|
||||||
isLoading: _isBusy,
|
isLoading: _isBusy,
|
||||||
|
10
lib/screens/post/post_editor.dart
Normal file
10
lib/screens/post/post_editor.dart
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class PostEditorScreen extends StatelessWidget {
|
||||||
|
const PostEditorScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return const Placeholder();
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,8 @@ import 'package:surface/widgets/navigation/app_bottom_navigation.dart';
|
|||||||
|
|
||||||
class AppScaffold extends StatelessWidget {
|
class AppScaffold extends StatelessWidget {
|
||||||
final PreferredSizeWidget? appBar;
|
final PreferredSizeWidget? appBar;
|
||||||
|
final FloatingActionButtonLocation? floatingActionButtonLocation;
|
||||||
|
final Widget? floatingActionButton;
|
||||||
final String? title;
|
final String? title;
|
||||||
final Widget? body;
|
final Widget? body;
|
||||||
final bool autoImplyAppBar;
|
final bool autoImplyAppBar;
|
||||||
@ -15,6 +17,8 @@ class AppScaffold extends StatelessWidget {
|
|||||||
const AppScaffold({
|
const AppScaffold({
|
||||||
super.key,
|
super.key,
|
||||||
this.appBar,
|
this.appBar,
|
||||||
|
this.floatingActionButton,
|
||||||
|
this.floatingActionButtonLocation,
|
||||||
this.title,
|
this.title,
|
||||||
this.body,
|
this.body,
|
||||||
this.autoImplyAppBar = false,
|
this.autoImplyAppBar = false,
|
||||||
@ -44,6 +48,8 @@ class AppScaffold extends StatelessWidget {
|
|||||||
: null)
|
: null)
|
||||||
: null),
|
: null),
|
||||||
body: body,
|
body: body,
|
||||||
|
floatingActionButtonLocation: floatingActionButtonLocation,
|
||||||
|
floatingActionButton: floatingActionButton,
|
||||||
bottomNavigationBar:
|
bottomNavigationBar:
|
||||||
isShowBottomNavigation ? AppBottomNavigationBar() : null,
|
isShowBottomNavigation ? AppBottomNavigationBar() : null,
|
||||||
),
|
),
|
||||||
|
@ -459,6 +459,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.4.1"
|
version: "3.4.1"
|
||||||
|
flutter_expandable_fab:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_expandable_fab
|
||||||
|
sha256: "85275279d19faf4fbe5639dc1f139b4555b150e079d056f085601a45688af12c"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.0"
|
||||||
flutter_image_compress:
|
flutter_image_compress:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -64,6 +64,7 @@ dependencies:
|
|||||||
file_picker: ^8.1.3
|
file_picker: ^8.1.3
|
||||||
flutter_image_compress: ^2.3.0
|
flutter_image_compress: ^2.3.0
|
||||||
croppy: ^1.3.1
|
croppy: ^1.3.1
|
||||||
|
flutter_expandable_fab: ^2.3.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
Reference in New Issue
Block a user