2024-05-18 10:17:16 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:go_router/go_router.dart';
|
2024-05-18 16:56:32 +00:00
|
|
|
import 'package:solian/router.dart';
|
2024-05-18 10:17:16 +00:00
|
|
|
import 'package:solian/theme.dart';
|
2024-05-22 15:18:01 +00:00
|
|
|
import 'package:solian/widgets/prev_page.dart';
|
2024-05-18 10:17:16 +00:00
|
|
|
import 'package:solian/widgets/navigation/app_navigation_bottom_bar.dart';
|
|
|
|
import 'package:solian/widgets/navigation/app_navigation_rail.dart';
|
|
|
|
|
|
|
|
class NavShell extends StatelessWidget {
|
2024-05-23 14:11:42 +00:00
|
|
|
final bool showAppBar;
|
2024-05-18 10:17:16 +00:00
|
|
|
final GoRouterState state;
|
|
|
|
final Widget child;
|
|
|
|
|
2024-05-23 14:11:42 +00:00
|
|
|
const NavShell({
|
|
|
|
super.key,
|
|
|
|
required this.child,
|
|
|
|
required this.state,
|
|
|
|
this.showAppBar = true,
|
|
|
|
});
|
2024-05-18 10:17:16 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-05-18 16:56:32 +00:00
|
|
|
final canPop = AppRouter.instance.canPop();
|
|
|
|
|
2024-05-18 10:17:16 +00:00
|
|
|
return Scaffold(
|
2024-05-23 14:11:42 +00:00
|
|
|
appBar: showAppBar
|
|
|
|
? AppBar(
|
|
|
|
title: Text(state.topRoute?.name?.tr ?? 'page'.tr),
|
|
|
|
centerTitle: false,
|
|
|
|
titleSpacing: canPop ? null : 24,
|
|
|
|
elevation: SolianTheme.isLargeScreen(context) ? 1 : 0,
|
|
|
|
leading: canPop ? const PrevPageButton() : null,
|
|
|
|
automaticallyImplyLeading: false,
|
|
|
|
)
|
|
|
|
: null,
|
2024-05-22 15:18:01 +00:00
|
|
|
bottomNavigationBar: SolianTheme.isLargeScreen(context)
|
|
|
|
? null
|
|
|
|
: const AppNavigationBottomBar(),
|
2024-05-18 10:17:16 +00:00
|
|
|
body: SolianTheme.isLargeScreen(context)
|
|
|
|
? Row(
|
|
|
|
children: [
|
|
|
|
const AppNavigationRail(),
|
|
|
|
const VerticalDivider(thickness: 0.3, width: 1),
|
|
|
|
Expanded(child: child),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
: child,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|