✨ Expanded drawer nav
This commit is contained in:
parent
9c8dad0176
commit
455ffcac19
@ -97,9 +97,9 @@
|
|||||||
"postReact": "React",
|
"postReact": "React",
|
||||||
"postReactions": "Reactions of Post",
|
"postReactions": "Reactions of Post",
|
||||||
"postReactionPoints": {
|
"postReactionPoints": {
|
||||||
"zero": "{}pt",
|
"zero": "{} pt",
|
||||||
"one": "{}pt",
|
"one": "{} pt",
|
||||||
"other": "{}pts"
|
"other": "{} pts"
|
||||||
},
|
},
|
||||||
"postReactCompleted": "Reaction has been added.",
|
"postReactCompleted": "Reaction has been added.",
|
||||||
"postReactUncompleted": "Reaction has been removed.",
|
"postReactUncompleted": "Reaction has been removed.",
|
||||||
|
@ -10,15 +10,15 @@ import 'package:surface/widgets/attachment/attachment_item.dart';
|
|||||||
class AttachmentList extends StatelessWidget {
|
class AttachmentList extends StatelessWidget {
|
||||||
final List<SnAttachment> data;
|
final List<SnAttachment> data;
|
||||||
final bool? bordered;
|
final bool? bordered;
|
||||||
final double? maxListHeight;
|
final double? maxHeight;
|
||||||
const AttachmentList({
|
const AttachmentList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.data,
|
required this.data,
|
||||||
this.bordered,
|
this.bordered,
|
||||||
this.maxListHeight,
|
this.maxHeight,
|
||||||
});
|
});
|
||||||
|
|
||||||
static const double kMaxListItemWidth = 520;
|
static const double kMaxItemWidth = 520;
|
||||||
static const BorderRadius kDefaultRadius =
|
static const BorderRadius kDefaultRadius =
|
||||||
BorderRadius.all(Radius.circular(8));
|
BorderRadius.all(Radius.circular(8));
|
||||||
|
|
||||||
@ -33,9 +33,10 @@ class AttachmentList extends StatelessWidget {
|
|||||||
if (ResponsiveBreakpoints.of(context).largerThan(MOBILE)) {
|
if (ResponsiveBreakpoints.of(context).largerThan(MOBILE)) {
|
||||||
return Container(
|
return Container(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: maxHeight ?? double.infinity,
|
||||||
maxWidth: math.min(
|
maxWidth: math.min(
|
||||||
MediaQuery.of(context).size.width - 20,
|
MediaQuery.of(context).size.width - 20,
|
||||||
kMaxListItemWidth,
|
kMaxItemWidth,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -64,7 +65,7 @@ class AttachmentList extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
constraints: BoxConstraints(maxHeight: maxListHeight ?? 320),
|
constraints: BoxConstraints(maxHeight: maxHeight ?? 320),
|
||||||
child: ScrollConfiguration(
|
child: ScrollConfiguration(
|
||||||
behavior: _AttachmentListScrollBehavior(),
|
behavior: _AttachmentListScrollBehavior(),
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
@ -73,9 +74,10 @@ class AttachmentList extends StatelessWidget {
|
|||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
return Container(
|
return Container(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: maxHeight ?? double.infinity,
|
||||||
maxWidth: math.min(
|
maxWidth: math.min(
|
||||||
MediaQuery.of(context).size.width - 20,
|
MediaQuery.of(context).size.width - 20,
|
||||||
kMaxListItemWidth,
|
kMaxItemWidth,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
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:go_router/go_router.dart';
|
import 'package:go_router/go_router.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/navigation.dart';
|
import 'package:surface/providers/navigation.dart';
|
||||||
|
|
||||||
@ -27,6 +30,10 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final nav = context.watch<NavigationProvider>();
|
final nav = context.watch<NavigationProvider>();
|
||||||
|
|
||||||
|
final backgroundColor = ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
||||||
|
? Theme.of(context).colorScheme.surface
|
||||||
|
: null;
|
||||||
|
|
||||||
return ListenableBuilder(
|
return ListenableBuilder(
|
||||||
listenable: nav,
|
listenable: nav,
|
||||||
builder: (context, _) {
|
builder: (context, _) {
|
||||||
@ -36,6 +43,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return NavigationDrawer(
|
return NavigationDrawer(
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
selectedIndex: nav.currentIndex,
|
selectedIndex: nav.currentIndex,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
@ -48,7 +56,8 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
|||||||
],
|
],
|
||||||
).padding(
|
).padding(
|
||||||
horizontal: 32,
|
horizontal: 32,
|
||||||
vertical: 8,
|
top: math.max(MediaQuery.of(context).padding.top, 16),
|
||||||
|
bottom: 16,
|
||||||
),
|
),
|
||||||
...destinations.where((ele) => ele.isPinned).map((ele) {
|
...destinations.where((ele) => ele.isPinned).map((ele) {
|
||||||
return NavigationDrawerDestination(
|
return NavigationDrawerDestination(
|
||||||
|
@ -30,14 +30,16 @@ class AppScaffold extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final isShowDrawer = showDrawer;
|
final isShowDrawer = showDrawer
|
||||||
|
? ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
|
||||||
|
: false;
|
||||||
final isShowBottomNavigation = (showBottomNavigation)
|
final isShowBottomNavigation = (showBottomNavigation)
|
||||||
? (ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE))
|
? ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
final state = GoRouter.maybeOf(context);
|
final state = GoRouter.maybeOf(context);
|
||||||
|
|
||||||
return AppBackground(
|
final innerWidget = AppBackground(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: appBar ??
|
appBar: appBar ??
|
||||||
(autoImplyAppBar
|
(autoImplyAppBar
|
||||||
@ -59,5 +61,17 @@ class AppScaffold extends StatelessWidget {
|
|||||||
isShowBottomNavigation ? AppBottomNavigationBar() : null,
|
isShowBottomNavigation ? AppBottomNavigationBar() : null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (showDrawer) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
AppNavigationDrawer(),
|
||||||
|
VerticalDivider(width: 1, color: Theme.of(context).dividerColor),
|
||||||
|
Expanded(child: innerWidget),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return innerWidget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ 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:relative_time/relative_time.dart';
|
import 'package:relative_time/relative_time.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/userinfo.dart';
|
import 'package:surface/providers/userinfo.dart';
|
||||||
import 'package:surface/types/post.dart';
|
import 'package:surface/types/post.dart';
|
||||||
@ -33,6 +34,10 @@ class PostItem extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final isListAttachments =
|
||||||
|
ResponsiveBreakpoints.of(context).largerThan(MOBILE) ||
|
||||||
|
(data.preload?.attachments?.length ?? 0) > 1;
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -40,14 +45,14 @@ class PostItem extends StatelessWidget {
|
|||||||
_PostContentBody(data: data.body).padding(horizontal: 16, bottom: 6),
|
_PostContentBody(data: data.body).padding(horizontal: 16, bottom: 6),
|
||||||
if (data.repostTo != null)
|
if (data.repostTo != null)
|
||||||
_PostQuoteContent(child: data.repostTo!).padding(
|
_PostQuoteContent(child: data.repostTo!).padding(
|
||||||
horizontal: 8,
|
horizontal: 12,
|
||||||
bottom: 4,
|
|
||||||
),
|
),
|
||||||
if (data.preload?.attachments?.isNotEmpty ?? true)
|
if (data.preload?.attachments?.isNotEmpty ?? true)
|
||||||
AttachmentList(
|
AttachmentList(
|
||||||
data: data.preload!.attachments!,
|
data: data.preload!.attachments!,
|
||||||
bordered: true,
|
bordered: true,
|
||||||
),
|
maxHeight: 520,
|
||||||
|
).padding(horizontal: isListAttachments ? 12 : 0),
|
||||||
_PostBottomAction(
|
_PostBottomAction(
|
||||||
data: data,
|
data: data,
|
||||||
showComments: showComments,
|
showComments: showComments,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user