♻️ Refactored navigation
This commit is contained in:
parent
48b76ed574
commit
aa43eaa0eb
@ -17,7 +17,7 @@ import 'package:solian/screens/realms.dart';
|
|||||||
import 'package:solian/screens/realms/realm_detail.dart';
|
import 'package:solian/screens/realms/realm_detail.dart';
|
||||||
import 'package:solian/screens/realms/realm_organize.dart';
|
import 'package:solian/screens/realms/realm_organize.dart';
|
||||||
import 'package:solian/screens/realms/realm_view.dart';
|
import 'package:solian/screens/realms/realm_view.dart';
|
||||||
import 'package:solian/screens/feed.dart';
|
import 'package:solian/screens/home.dart';
|
||||||
import 'package:solian/screens/posts/post_editor.dart';
|
import 'package:solian/screens/posts/post_editor.dart';
|
||||||
import 'package:solian/shells/basic_shell.dart';
|
import 'package:solian/shells/basic_shell.dart';
|
||||||
import 'package:solian/shells/root_shell.dart';
|
import 'package:solian/shells/root_shell.dart';
|
||||||
@ -48,8 +48,8 @@ abstract class AppRouter {
|
|||||||
routes: [
|
routes: [
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'feed',
|
name: 'home',
|
||||||
builder: (context, state) => const FeedScreen(),
|
builder: (context, state) => const HomeScreen(),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/feed/search',
|
path: '/feed/search',
|
||||||
|
@ -4,7 +4,7 @@ import 'package:solian/exts.dart';
|
|||||||
import 'package:solian/models/articles.dart';
|
import 'package:solian/models/articles.dart';
|
||||||
import 'package:solian/providers/content/feed.dart';
|
import 'package:solian/providers/content/feed.dart';
|
||||||
import 'package:solian/widgets/articles/article_item.dart';
|
import 'package:solian/widgets/articles/article_item.dart';
|
||||||
import 'package:solian/widgets/centered_container.dart';
|
import 'package:solian/widgets/sized_container.dart';
|
||||||
|
|
||||||
class ArticleDetailScreen extends StatefulWidget {
|
class ArticleDetailScreen extends StatefulWidget {
|
||||||
final String alias;
|
final String alias;
|
||||||
|
@ -10,7 +10,6 @@ import 'package:solian/theme.dart';
|
|||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
import 'package:solian/widgets/attachments/attachment_publish.dart';
|
import 'package:solian/widgets/attachments/attachment_publish.dart';
|
||||||
import 'package:solian/widgets/feed/feed_tags_field.dart';
|
import 'package:solian/widgets/feed/feed_tags_field.dart';
|
||||||
import 'package:solian/widgets/prev_page.dart';
|
|
||||||
import 'package:textfield_tags/textfield_tags.dart';
|
import 'package:textfield_tags/textfield_tags.dart';
|
||||||
import 'package:badges/badges.dart' as badges;
|
import 'package:badges/badges.dart' as badges;
|
||||||
|
|
||||||
@ -133,7 +132,6 @@ class _ArticlePublishScreenState extends State<ArticlePublishScreen> {
|
|||||||
title: AppBarTitle('articlePublish'.tr),
|
title: AppBarTitle('articlePublish'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
leading: const PrevPageButton(),
|
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: _isBusy ? null : () => applyPost(),
|
onPressed: _isBusy ? null : () => applyPost(),
|
||||||
|
@ -7,7 +7,6 @@ import 'package:solian/providers/content/call.dart';
|
|||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
import 'package:solian/widgets/chat/call/call_controls.dart';
|
import 'package:solian/widgets/chat/call/call_controls.dart';
|
||||||
import 'package:solian/widgets/chat/call/call_participant.dart';
|
import 'package:solian/widgets/chat/call/call_participant.dart';
|
||||||
import 'package:solian/widgets/prev_page.dart';
|
|
||||||
|
|
||||||
class CallScreen extends StatefulWidget {
|
class CallScreen extends StatefulWidget {
|
||||||
const CallScreen({super.key});
|
const CallScreen({super.key});
|
||||||
@ -72,7 +71,6 @@ class _CallScreenState extends State<CallScreen> {
|
|||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
leading: const PrevPageButton(),
|
|
||||||
),
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Obx(
|
child: Obx(
|
||||||
|
@ -9,7 +9,6 @@ import 'package:solian/providers/content/channel.dart';
|
|||||||
import 'package:solian/router.dart';
|
import 'package:solian/router.dart';
|
||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
import 'package:solian/widgets/prev_page.dart';
|
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
class ChannelOrganizeArguments {
|
class ChannelOrganizeArguments {
|
||||||
@ -112,7 +111,6 @@ class _ChannelOrganizeScreenState extends State<ChannelOrganizeScreen> {
|
|||||||
title: AppBarTitle('channelOrganizing'.tr),
|
title: AppBarTitle('channelOrganizing'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
leading: const PrevPageButton(),
|
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: _isBusy ? null : () => applyChannel(),
|
onPressed: _isBusy ? null : () => applyChannel(),
|
||||||
|
@ -12,7 +12,6 @@ import 'package:solian/widgets/app_bar_title.dart';
|
|||||||
import 'package:solian/widgets/channel/channel_list.dart';
|
import 'package:solian/widgets/channel/channel_list.dart';
|
||||||
import 'package:solian/widgets/chat/call/chat_call_indicator.dart';
|
import 'package:solian/widgets/chat/call/chat_call_indicator.dart';
|
||||||
import 'package:solian/widgets/current_state_action.dart';
|
import 'package:solian/widgets/current_state_action.dart';
|
||||||
import 'package:solian/widgets/drawer_button.dart' as drawer;
|
|
||||||
|
|
||||||
class ChatScreen extends StatefulWidget {
|
class ChatScreen extends StatefulWidget {
|
||||||
const ChatScreen({super.key});
|
const ChatScreen({super.key});
|
||||||
@ -95,7 +94,6 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
title: AppBarTitle('chat'.tr),
|
title: AppBarTitle('chat'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
floating: true,
|
floating: true,
|
||||||
leading: const drawer.DrawerButton(),
|
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
actions: [
|
actions: [
|
||||||
const BackgroundStateWidget(),
|
const BackgroundStateWidget(),
|
||||||
|
@ -6,14 +6,13 @@ import 'package:solian/models/feed.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/feed.dart';
|
import 'package:solian/providers/content/feed.dart';
|
||||||
import 'package:solian/screens/feed.dart';
|
import 'package:solian/screens/home.dart';
|
||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
import 'package:solian/widgets/articles/article_action.dart';
|
import 'package:solian/widgets/articles/article_action.dart';
|
||||||
import 'package:solian/widgets/articles/article_owned_list.dart';
|
import 'package:solian/widgets/articles/article_owned_list.dart';
|
||||||
import 'package:solian/widgets/posts/post_action.dart';
|
import 'package:solian/widgets/posts/post_action.dart';
|
||||||
import 'package:solian/widgets/posts/post_owned_list.dart';
|
import 'package:solian/widgets/posts/post_owned_list.dart';
|
||||||
import 'package:solian/widgets/prev_page.dart';
|
|
||||||
|
|
||||||
class DraftBoxScreen extends StatefulWidget {
|
class DraftBoxScreen extends StatefulWidget {
|
||||||
const DraftBoxScreen({super.key});
|
const DraftBoxScreen({super.key});
|
||||||
@ -66,7 +65,6 @@ class _DraftBoxScreenState extends State<DraftBoxScreen> {
|
|||||||
title: AppBarTitle('draftBox'.tr),
|
title: AppBarTitle('draftBox'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
leading: const PrevPageButton(),
|
|
||||||
actions: [
|
actions: [
|
||||||
FeedCreationButton(
|
FeedCreationButton(
|
||||||
hideDraftBox: true,
|
hideDraftBox: true,
|
||||||
|
@ -11,16 +11,15 @@ import 'package:solian/theme.dart';
|
|||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
import 'package:solian/widgets/current_state_action.dart';
|
import 'package:solian/widgets/current_state_action.dart';
|
||||||
import 'package:solian/widgets/feed/feed_list.dart';
|
import 'package:solian/widgets/feed/feed_list.dart';
|
||||||
import 'package:solian/widgets/drawer_button.dart' as drawer;
|
|
||||||
|
|
||||||
class FeedScreen extends StatefulWidget {
|
class HomeScreen extends StatefulWidget {
|
||||||
const FeedScreen({super.key});
|
const HomeScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<FeedScreen> createState() => _FeedScreenState();
|
State<HomeScreen> createState() => _HomeScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FeedScreenState extends State<FeedScreen> {
|
class _HomeScreenState extends State<HomeScreen> {
|
||||||
final PagingController<int, FeedRecord> _pagingController =
|
final PagingController<int, FeedRecord> _pagingController =
|
||||||
PagingController(firstPageKey: 0);
|
PagingController(firstPageKey: 0);
|
||||||
|
|
||||||
@ -60,11 +59,10 @@ class _FeedScreenState extends State<FeedScreen> {
|
|||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverAppBar(
|
SliverAppBar(
|
||||||
title: AppBarTitle('feed'.tr),
|
title: AppBarTitle('home'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
floating: true,
|
floating: true,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
leading: const drawer.DrawerButton(),
|
|
||||||
actions: [
|
actions: [
|
||||||
const BackgroundStateWidget(),
|
const BackgroundStateWidget(),
|
||||||
const NotificationButton(),
|
const NotificationButton(),
|
@ -3,7 +3,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:solian/exts.dart';
|
import 'package:solian/exts.dart';
|
||||||
import 'package:solian/models/post.dart';
|
import 'package:solian/models/post.dart';
|
||||||
import 'package:solian/providers/content/feed.dart';
|
import 'package:solian/providers/content/feed.dart';
|
||||||
import 'package:solian/widgets/centered_container.dart';
|
import 'package:solian/widgets/sized_container.dart';
|
||||||
import 'package:solian/widgets/posts/post_item.dart';
|
import 'package:solian/widgets/posts/post_item.dart';
|
||||||
import 'package:solian/widgets/posts/post_replies.dart';
|
import 'package:solian/widgets/posts/post_replies.dart';
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import 'package:solian/widgets/app_bar_title.dart';
|
|||||||
import 'package:solian/widgets/attachments/attachment_publish.dart';
|
import 'package:solian/widgets/attachments/attachment_publish.dart';
|
||||||
import 'package:solian/widgets/posts/post_item.dart';
|
import 'package:solian/widgets/posts/post_item.dart';
|
||||||
import 'package:solian/widgets/feed/feed_tags_field.dart';
|
import 'package:solian/widgets/feed/feed_tags_field.dart';
|
||||||
import 'package:solian/widgets/prev_page.dart';
|
|
||||||
import 'package:textfield_tags/textfield_tags.dart';
|
import 'package:textfield_tags/textfield_tags.dart';
|
||||||
import 'package:badges/badges.dart' as badges;
|
import 'package:badges/badges.dart' as badges;
|
||||||
|
|
||||||
@ -137,7 +136,6 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
title: AppBarTitle('postPublish'.tr),
|
title: AppBarTitle('postPublish'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
leading: const PrevPageButton(),
|
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: _isBusy ? null : () => applyPost(),
|
onPressed: _isBusy ? null : () => applyPost(),
|
||||||
|
@ -11,7 +11,6 @@ import 'package:solian/theme.dart';
|
|||||||
import 'package:solian/widgets/account/signin_required_overlay.dart';
|
import 'package:solian/widgets/account/signin_required_overlay.dart';
|
||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
import 'package:solian/widgets/current_state_action.dart';
|
import 'package:solian/widgets/current_state_action.dart';
|
||||||
import 'package:solian/widgets/drawer_button.dart' as drawer;
|
|
||||||
|
|
||||||
class RealmListScreen extends StatefulWidget {
|
class RealmListScreen extends StatefulWidget {
|
||||||
const RealmListScreen({super.key});
|
const RealmListScreen({super.key});
|
||||||
@ -80,7 +79,6 @@ class _RealmListScreenState extends State<RealmListScreen> {
|
|||||||
title: AppBarTitle('realm'.tr),
|
title: AppBarTitle('realm'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
floating: true,
|
floating: true,
|
||||||
leading: const drawer.DrawerButton(),
|
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
actions: [
|
actions: [
|
||||||
const BackgroundStateWidget(),
|
const BackgroundStateWidget(),
|
||||||
|
@ -7,7 +7,6 @@ import 'package:solian/providers/auth.dart';
|
|||||||
import 'package:solian/router.dart';
|
import 'package:solian/router.dart';
|
||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
import 'package:solian/widgets/prev_page.dart';
|
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
class RealmOrganizeArguments {
|
class RealmOrganizeArguments {
|
||||||
@ -102,7 +101,6 @@ class _RealmOrganizeScreenState extends State<RealmOrganizeScreen> {
|
|||||||
title: AppBarTitle('realmOrganizing'.tr),
|
title: AppBarTitle('realmOrganizing'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
leading: const PrevPageButton(),
|
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: _isBusy ? null : () => applyRealm(),
|
onPressed: _isBusy ? null : () => applyRealm(),
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:solian/router.dart';
|
|
||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
import 'package:solian/widgets/prev_page.dart';
|
|
||||||
import 'package:solian/widgets/sidebar/sidebar_placeholder.dart';
|
import 'package:solian/widgets/sidebar/sidebar_placeholder.dart';
|
||||||
|
|
||||||
class BasicShell extends StatelessWidget {
|
class BasicShell extends StatelessWidget {
|
||||||
@ -42,16 +40,12 @@ class BasicShell extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final canPop = AppRouter.instance.canPop();
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: showAppBar
|
appBar: showAppBar
|
||||||
? AppBar(
|
? AppBar(
|
||||||
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
|
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
leading: canPop ? const PrevPageButton() : null,
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
body: SolianTheme.isLargeScreen(context)
|
body: SolianTheme.isLargeScreen(context)
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:solian/router.dart';
|
|
||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
import 'package:solian/widgets/prev_page.dart';
|
|
||||||
|
|
||||||
class CenteredShell extends StatelessWidget {
|
class CenteredShell extends StatelessWidget {
|
||||||
final bool showAppBar;
|
final bool showAppBar;
|
||||||
@ -20,16 +18,12 @@ class CenteredShell extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final canPop = AppRouter.instance.canPop();
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: showAppBar
|
appBar: showAppBar
|
||||||
? AppBar(
|
? AppBar(
|
||||||
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
|
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
leading: canPop ? const PrevPageButton() : null,
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
body: Center(
|
body: Center(
|
||||||
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
import 'package:solian/widgets/navigation/app_navigation_drawer.dart';
|
import 'package:solian/widgets/navigation/app_navigation_drawer.dart';
|
||||||
import 'package:solian/widgets/navigation/app_navigation_rail.dart';
|
|
||||||
|
|
||||||
final GlobalKey<ScaffoldState> rootScaffoldKey = GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> rootScaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
@ -32,14 +31,16 @@ class RootShell extends StatelessWidget {
|
|||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: rootScaffoldKey,
|
key: rootScaffoldKey,
|
||||||
drawer: AppNavigationDrawer(
|
drawer: SolianTheme.isLargeScreen(context)
|
||||||
|
? null
|
||||||
|
: AppNavigationDrawer(
|
||||||
key: const ValueKey('navigation-drawer'),
|
key: const ValueKey('navigation-drawer'),
|
||||||
routeName: routeName,
|
routeName: routeName,
|
||||||
),
|
),
|
||||||
body: SolianTheme.isLargeScreen(context)
|
body: SolianTheme.isLargeScreen(context)
|
||||||
? Row(
|
? Row(
|
||||||
children: [
|
children: [
|
||||||
if (showNavigation) const AppNavigationRail(),
|
if (showNavigation) AppNavigationDrawer(routeName: routeName),
|
||||||
if (showNavigation)
|
if (showNavigation)
|
||||||
const VerticalDivider(thickness: 0.3, width: 1),
|
const VerticalDivider(thickness: 0.3, width: 1),
|
||||||
Expanded(child: child),
|
Expanded(child: child),
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:solian/router.dart';
|
|
||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
import 'package:solian/widgets/prev_page.dart' as prev;
|
|
||||||
import 'package:solian/widgets/drawer_button.dart' as drawer;
|
|
||||||
|
|
||||||
class TitleShell extends StatelessWidget {
|
class TitleShell extends StatelessWidget {
|
||||||
final bool showAppBar;
|
final bool showAppBar;
|
||||||
@ -21,18 +18,12 @@ class TitleShell extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final canPop = AppRouter.instance.canPop();
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: showAppBar
|
appBar: showAppBar
|
||||||
? AppBar(
|
? AppBar(
|
||||||
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
|
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
leading: canPop
|
|
||||||
? const prev.PrevPageButton()
|
|
||||||
: const drawer.DrawerButton(),
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
body: child,
|
body: child,
|
||||||
|
@ -5,6 +5,7 @@ const messagesEnglish = {
|
|||||||
'next': 'Next',
|
'next': 'Next',
|
||||||
'reset': 'Reset',
|
'reset': 'Reset',
|
||||||
'page': 'Page',
|
'page': 'Page',
|
||||||
|
'home': 'Home',
|
||||||
'draft': 'Draft',
|
'draft': 'Draft',
|
||||||
'draftSave': 'Save',
|
'draftSave': 'Save',
|
||||||
'draftBox': 'Draft Box',
|
'draftBox': 'Draft Box',
|
||||||
|
@ -2,6 +2,7 @@ const simplifiedChineseMessages = {
|
|||||||
'done': '完成',
|
'done': '完成',
|
||||||
'hide': '隐藏',
|
'hide': '隐藏',
|
||||||
'okay': '确认',
|
'okay': '确认',
|
||||||
|
'home': '首页',
|
||||||
'next': '下一步',
|
'next': '下一步',
|
||||||
'reset': '重置',
|
'reset': '重置',
|
||||||
'cancel': '取消',
|
'cancel': '取消',
|
||||||
|
@ -5,7 +5,7 @@ import 'package:solian/models/articles.dart';
|
|||||||
import 'package:solian/router.dart';
|
import 'package:solian/router.dart';
|
||||||
import 'package:solian/widgets/articles/article_action.dart';
|
import 'package:solian/widgets/articles/article_action.dart';
|
||||||
import 'package:solian/widgets/articles/article_item.dart';
|
import 'package:solian/widgets/articles/article_item.dart';
|
||||||
import 'package:solian/widgets/centered_container.dart';
|
import 'package:solian/widgets/sized_container.dart';
|
||||||
|
|
||||||
class ArticleListWidget extends StatelessWidget {
|
class ArticleListWidget extends StatelessWidget {
|
||||||
final bool isShowEmbed;
|
final bool isShowEmbed;
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:solian/shells/root_shell.dart';
|
|
||||||
|
|
||||||
class DrawerButton extends StatelessWidget {
|
|
||||||
const DrawerButton({super.key});
|
|
||||||
|
|
||||||
void openDrawer() {
|
|
||||||
rootScaffoldKey.currentState!.openDrawer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return IconButton(
|
|
||||||
icon: const Icon(Icons.menu),
|
|
||||||
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
|
|
||||||
onPressed: openDrawer,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,7 +4,7 @@ import 'package:solian/models/articles.dart';
|
|||||||
import 'package:solian/models/feed.dart';
|
import 'package:solian/models/feed.dart';
|
||||||
import 'package:solian/models/post.dart';
|
import 'package:solian/models/post.dart';
|
||||||
import 'package:solian/widgets/articles/article_list.dart';
|
import 'package:solian/widgets/articles/article_list.dart';
|
||||||
import 'package:solian/widgets/centered_container.dart';
|
import 'package:solian/widgets/sized_container.dart';
|
||||||
import 'package:solian/widgets/posts/post_list.dart';
|
import 'package:solian/widgets/posts/post_list.dart';
|
||||||
|
|
||||||
class FeedListWidget extends StatelessWidget {
|
class FeedListWidget extends StatelessWidget {
|
||||||
@ -28,7 +28,7 @@ class FeedListWidget extends StatelessWidget {
|
|||||||
pagingController: controller,
|
pagingController: controller,
|
||||||
builderDelegate: PagedChildBuilderDelegate<FeedRecord>(
|
builderDelegate: PagedChildBuilderDelegate<FeedRecord>(
|
||||||
itemBuilder: (context, item, index) {
|
itemBuilder: (context, item, index) {
|
||||||
return CenteredContainer(
|
return SizedContainer(
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
|
@ -4,9 +4,9 @@ import 'package:get/utils.dart';
|
|||||||
abstract class AppNavigation {
|
abstract class AppNavigation {
|
||||||
static List<AppNavigationDestination> destinations = [
|
static List<AppNavigationDestination> destinations = [
|
||||||
AppNavigationDestination(
|
AppNavigationDestination(
|
||||||
icon: const Icon(Icons.feed),
|
icon: const Icon(Icons.home),
|
||||||
label: 'feed'.tr,
|
label: 'home'.tr,
|
||||||
page: 'feed',
|
page: 'home',
|
||||||
),
|
),
|
||||||
AppNavigationDestination(
|
AppNavigationDestination(
|
||||||
icon: const Icon(Icons.forum),
|
icon: const Icon(Icons.forum),
|
||||||
@ -18,11 +18,6 @@ abstract class AppNavigation {
|
|||||||
label: 'realms'.tr,
|
label: 'realms'.tr,
|
||||||
page: 'realms',
|
page: 'realms',
|
||||||
),
|
),
|
||||||
AppNavigationDestination(
|
|
||||||
icon: const Icon(Icons.account_circle),
|
|
||||||
label: 'account'.tr,
|
|
||||||
page: 'account',
|
|
||||||
),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
static List<String> get destinationPages =>
|
static List<String> get destinationPages =>
|
||||||
|
@ -20,7 +20,7 @@ class AppNavigationDrawer extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||||
int _selectedIndex = 0;
|
int? _selectedIndex = 0;
|
||||||
AccountStatus? _accountStatus;
|
AccountStatus? _accountStatus;
|
||||||
|
|
||||||
void getStatus() async {
|
void getStatus() async {
|
||||||
@ -40,7 +40,11 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
|||||||
final nameList = AppNavigation.destinations.map((x) => x.page).toList();
|
final nameList = AppNavigation.destinations.map((x) => x.page).toList();
|
||||||
final idx = nameList.indexOf(widget.routeName!);
|
final idx = nameList.indexOf(widget.routeName!);
|
||||||
|
|
||||||
_selectedIndex = idx != -1 ? idx : 0;
|
_selectedIndex = idx != -1 ? idx : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
void closeDrawer() {
|
||||||
|
rootScaffoldKey.currentState!.closeDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -65,7 +69,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
|||||||
onDestinationSelected: (idx) {
|
onDestinationSelected: (idx) {
|
||||||
setState(() => _selectedIndex = idx);
|
setState(() => _selectedIndex = idx);
|
||||||
AppRouter.instance.goNamed(AppNavigation.destinations[idx].page);
|
AppRouter.instance.goNamed(AppNavigation.destinations[idx].page);
|
||||||
rootScaffoldKey.currentState!.closeDrawer();
|
closeDrawer();
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
@ -75,9 +79,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
|||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Column(
|
return ListTile(
|
||||||
children: [
|
|
||||||
ListTile(
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
title: Text(snapshot.data!.body['nick']),
|
title: Text(snapshot.data!.body['nick']),
|
||||||
subtitle: Builder(
|
subtitle: Builder(
|
||||||
@ -110,7 +112,9 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
onTap: () {
|
trailing: IconButton(
|
||||||
|
icon: const Icon(Icons.face_retouching_natural),
|
||||||
|
onPressed: () {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
context: context,
|
context: context,
|
||||||
@ -122,20 +126,27 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Divider(thickness: 0.3, height: 1).paddingOnly(
|
onTap: () {
|
||||||
bottom: 16,
|
AppRouter.instance.goNamed('account');
|
||||||
top: 8,
|
closeDrawer();
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
).paddingOnly(top: 8);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Divider(thickness: 0.3, height: 1).paddingOnly(
|
||||||
|
bottom: 12,
|
||||||
|
top: 8,
|
||||||
),
|
),
|
||||||
...AppNavigation.destinations.map(
|
...AppNavigation.destinations.map(
|
||||||
(e) => NavigationDrawerDestination(
|
(e) => NavigationDrawerDestination(
|
||||||
icon: e.icon,
|
icon: e.icon,
|
||||||
label: Text(e.label),
|
label: Text(e.label),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
const Divider(thickness: 0.3, height: 1).paddingOnly(
|
||||||
|
top: 12,
|
||||||
|
bottom: 8,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:solian/router.dart';
|
|
||||||
import 'package:solian/widgets/navigation/app_navigation.dart';
|
|
||||||
|
|
||||||
class AppNavigationRail extends StatefulWidget {
|
|
||||||
const AppNavigationRail({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<AppNavigationRail> createState() => _AppNavigationRailState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AppNavigationRailState extends State<AppNavigationRail> {
|
|
||||||
int _selectedIndex = 0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return NavigationRail(
|
|
||||||
destinations: AppNavigation.destinations
|
|
||||||
.map(
|
|
||||||
(e) => NavigationRailDestination(
|
|
||||||
icon: e.icon,
|
|
||||||
label: Text(e.label),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
groupAlignment: 0,
|
|
||||||
labelType: NavigationRailLabelType.all,
|
|
||||||
selectedIndex: _selectedIndex,
|
|
||||||
onDestinationSelected: (idx) {
|
|
||||||
setState(() => _selectedIndex = idx);
|
|
||||||
AppRouter.instance
|
|
||||||
.pushReplacementNamed(AppNavigation.destinations[idx].page);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,7 +3,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||||
import 'package:solian/models/post.dart';
|
import 'package:solian/models/post.dart';
|
||||||
import 'package:solian/router.dart';
|
import 'package:solian/router.dart';
|
||||||
import 'package:solian/widgets/centered_container.dart';
|
import 'package:solian/widgets/sized_container.dart';
|
||||||
import 'package:solian/widgets/posts/post_action.dart';
|
import 'package:solian/widgets/posts/post_action.dart';
|
||||||
import 'package:solian/widgets/posts/post_item.dart';
|
import 'package:solian/widgets/posts/post_item.dart';
|
||||||
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:solian/router.dart';
|
|
||||||
|
|
||||||
class PrevPageButton extends StatelessWidget {
|
|
||||||
const PrevPageButton({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return IconButton(
|
|
||||||
icon: const Icon(Icons.arrow_back),
|
|
||||||
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
|
|
||||||
onPressed: () {
|
|
||||||
if (AppRouter.instance.canPop()) {
|
|
||||||
AppRouter.instance.pop();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,27 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class SizedContainer extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
final double maxWidth;
|
||||||
|
|
||||||
|
const SizedContainer({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
this.maxWidth = 720,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: Container(
|
||||||
|
constraints: BoxConstraints(maxWidth: maxWidth),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class CenteredContainer extends StatelessWidget {
|
class CenteredContainer extends StatelessWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final double maxWidth;
|
final double maxWidth;
|
Loading…
Reference in New Issue
Block a user