♻️ Explore two column

This commit is contained in:
LittleSheep 2025-03-27 22:58:06 +08:00
parent 0722c99f21
commit 595050f89f
5 changed files with 68 additions and 43 deletions

View File

@ -70,10 +70,42 @@ final _appRoutes = [
name: 'home', name: 'home',
builder: (context, state) => const HomeScreen(), builder: (context, state) => const HomeScreen(),
), ),
ShellRoute(
builder: (context, state, child) => ResponsiveScaffold(
asideFlex: 2,
contentFlex: 3,
aside: const ExploreScreen(),
child: child,
),
routes: [
GoRoute(
path: '/explore',
name: 'explore',
builder: (context, state) => const ResponsiveScaffoldLanding(
child: ExploreScreen(),
),
),
GoRoute(
path: '/posts/:slug',
name: 'postDetail',
builder: (context, state) => PostDetailScreen(
key: ValueKey(state.pathParameters['slug']!),
slug: state.pathParameters['slug']!,
preload: state.extra as SnPost?,
),
),
GoRoute(
path: '/publishers/:name',
name: 'postPublisher',
builder: (context, state) =>
PostPublisherScreen(name: state.pathParameters['name']!),
),
],
),
GoRoute( GoRoute(
path: '/posts', path: '/posts',
name: 'explore', name: 'posts',
builder: (context, state) => const ExploreScreen(), builder: (_, __) => const SizedBox.shrink(),
routes: [ routes: [
GoRoute( GoRoute(
path: '/draft', path: '/draft',
@ -111,20 +143,6 @@ final _appRoutes = [
state.uri.queryParameters['categories']?.split(','), state.uri.queryParameters['categories']?.split(','),
), ),
), ),
GoRoute(
path: '/publishers/:name',
name: 'postPublisher',
builder: (context, state) =>
PostPublisherScreen(name: state.pathParameters['name']!),
),
GoRoute(
path: '/:slug',
name: 'postDetail',
builder: (context, state) => PostDetailScreen(
slug: state.pathParameters['slug']!,
preload: state.extra as SnPost?,
),
),
], ],
), ),
ShellRoute( ShellRoute(

View File

@ -243,6 +243,7 @@ class _ExploreScreenState extends State<ExploreScreen>
GoRouter.of(context).pushNamed('postShuffle'); GoRouter.of(context).pushNamed('postShuffle');
}, },
), ),
const Gap(48),
Expanded( Expanded(
child: Center( child: Center(
child: IconButton( child: IconButton(
@ -534,6 +535,7 @@ class _PostListWidgetState extends State<_PostListWidget> {
switch (ele.type) { switch (ele.type) {
case 'interactive.post': case 'interactive.post':
return OpenablePostItem( return OpenablePostItem(
useReplace: true,
data: SnPost.fromJson(ele.data), data: SnPost.fromJson(ele.data),
maxWidth: 640, maxWidth: 640,
onChanged: (data) { onChanged: (data) {

View File

@ -228,8 +228,15 @@ class AppRootScaffold extends StatelessWidget {
class ResponsiveScaffold extends StatelessWidget { class ResponsiveScaffold extends StatelessWidget {
final Widget aside; final Widget aside;
final Widget? child; final Widget? child;
const ResponsiveScaffold( final int asideFlex;
{super.key, required this.aside, required this.child}); final int contentFlex;
const ResponsiveScaffold({
super.key,
required this.aside,
required this.child,
this.asideFlex = 1,
this.contentFlex = 2,
});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -237,15 +244,15 @@ class ResponsiveScaffold extends StatelessWidget {
return Row( return Row(
children: [ children: [
Flexible( Flexible(
flex: 1, flex: asideFlex,
child: aside, child: aside,
), ),
VerticalDivider(width: 1), VerticalDivider(width: 1),
if (child != null && child != aside) if (child != null && child != aside)
Flexible(flex: 2, child: child!) Flexible(flex: contentFlex, child: child!)
else else
const Flexible( Flexible(
flex: 2, flex: contentFlex,
child: ResponsiveScaffoldLanding(child: null), child: ResponsiveScaffoldLanding(child: null),
), ),
], ],

View File

@ -4,7 +4,6 @@ import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:material_symbols_icons/symbols.dart'; import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/post.dart'; import 'package:surface/providers/post.dart';
import 'package:surface/providers/sn_network.dart'; import 'package:surface/providers/sn_network.dart';
@ -30,24 +29,14 @@ class PostCommentQuickAction extends StatelessWidget {
return Container( return Container(
height: 240, height: 240,
constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity), constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity),
margin: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
? const EdgeInsets.symmetric(vertical: 8)
: EdgeInsets.zero,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: ResponsiveBreakpoints.of(context).largerThan(MOBILE) borderRadius: BorderRadius.zero,
? const BorderRadius.all(Radius.circular(8)) border: Border.symmetric(
: BorderRadius.zero, horizontal: BorderSide(
border: ResponsiveBreakpoints.of(context).largerThan(MOBILE) color: Theme.of(context).dividerColor,
? Border.all( width: 1 / devicePixelRatio,
color: Theme.of(context).dividerColor, ),
width: 1 / devicePixelRatio, ),
)
: Border.symmetric(
horizontal: BorderSide(
color: Theme.of(context).dividerColor,
width: 1 / devicePixelRatio,
),
),
), ),
child: PostMiniEditor( child: PostMiniEditor(
postReplyId: parentPost.id, postReplyId: parentPost.id,

View File

@ -51,6 +51,7 @@ class OpenablePostItem extends StatelessWidget {
final bool showMenu; final bool showMenu;
final bool showFullPost; final bool showFullPost;
final bool showExpandableComments; final bool showExpandableComments;
final bool useReplace;
final double? maxWidth; final double? maxWidth;
final Function(SnPost data)? onChanged; final Function(SnPost data)? onChanged;
final Function()? onDeleted; final Function()? onDeleted;
@ -64,6 +65,7 @@ class OpenablePostItem extends StatelessWidget {
this.showMenu = true, this.showMenu = true,
this.showFullPost = false, this.showFullPost = false,
this.showExpandableComments = false, this.showExpandableComments = false,
this.useReplace = false,
this.maxWidth, this.maxWidth,
this.onChanged, this.onChanged,
this.onDeleted, this.onDeleted,
@ -87,9 +89,16 @@ class OpenablePostItem extends StatelessWidget {
onSelectAnswer: onSelectAnswer, onSelectAnswer: onSelectAnswer,
), ),
onTap: () { onTap: () {
GoRouter.of(context).pushNamed('postDetail', pathParameters: { if (useReplace) {
'slug': data.id.toString(), GoRouter.of(context)
}); .pushReplacementNamed('postDetail', pathParameters: {
'slug': data.id.toString(),
});
} else {
GoRouter.of(context).pushNamed('postDetail', pathParameters: {
'slug': data.id.toString(),
});
}
}, },
), ),
), ),