2023-11-01 20:36:16 +03:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:go_router/go_router.dart';
|
2024-08-20 01:52:44 -04:00
|
|
|
import 'package:hiddify/bootstrap.dart';
|
2023-11-01 20:36:16 +03:30
|
|
|
import 'package:hiddify/core/router/router.dart';
|
|
|
|
|
import 'package:hiddify/features/common/adaptive_root_scaffold.dart';
|
2024-08-20 01:52:44 -04:00
|
|
|
import 'package:hiddify/utils/utils.dart';
|
2023-11-01 20:36:16 +03:30
|
|
|
|
|
|
|
|
bool showDrawerButton(BuildContext context) {
|
|
|
|
|
if (!useMobileRouter) return true;
|
|
|
|
|
final String location = GoRouterState.of(context).uri.path;
|
2024-08-20 01:52:44 -04:00
|
|
|
if (location == const HomeRoute().location || location == const ProfilesOverviewRoute().location) return true;
|
2023-11-01 20:36:16 +03:30
|
|
|
if (location.startsWith(const ProxiesRoute().location)) return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class NestedAppBar extends StatelessWidget {
|
|
|
|
|
const NestedAppBar({
|
|
|
|
|
super.key,
|
|
|
|
|
this.title,
|
|
|
|
|
this.actions,
|
|
|
|
|
this.pinned = true,
|
|
|
|
|
this.forceElevated = false,
|
|
|
|
|
this.bottom,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
final Widget? title;
|
|
|
|
|
final List<Widget>? actions;
|
|
|
|
|
final bool pinned;
|
|
|
|
|
final bool forceElevated;
|
|
|
|
|
final PreferredSizeWidget? bottom;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
RootScaffold.canShowDrawer(context);
|
|
|
|
|
|
|
|
|
|
return SliverAppBar(
|
2024-08-20 01:52:44 -04:00
|
|
|
leading: (RootScaffold.stateKey.currentState?.hasDrawer ?? false) && showDrawerButton(context)
|
2023-11-01 20:36:16 +03:30
|
|
|
? DrawerButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
RootScaffold.stateKey.currentState?.openDrawer();
|
|
|
|
|
},
|
|
|
|
|
)
|
2024-08-31 11:57:39 +08:00
|
|
|
: IconButton(
|
|
|
|
|
icon: Icon(context.isRtl ? Icons.arrow_forward : Icons.arrow_back),
|
|
|
|
|
padding: EdgeInsets.only(right: context.isRtl ? 50 : 0),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (Navigator.of(context).canPop()){
|
|
|
|
|
Navigator.of(context).pop(); // Pops the current route off the navigator stack
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
2023-11-01 20:36:16 +03:30
|
|
|
title: title,
|
|
|
|
|
actions: actions,
|
|
|
|
|
pinned: pinned,
|
|
|
|
|
forceElevated: forceElevated,
|
|
|
|
|
bottom: bottom,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|