Skip to content

PageBranch widget for Dashboard (#848) #849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/screens/common_widgets/common_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export 'envvar_span.dart';
export 'sidebar_filter.dart';
export 'sidebar_header.dart';
export 'sidebar_save_button.dart';
export 'dashboard_page_branch.dart';
50 changes: 50 additions & 0 deletions lib/screens/common_widgets/dashboard_page_branch.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'package:apidash_design_system/apidash_design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../mobile/requests_page/requests_page.dart';
import '../envvar/environment_page.dart';
import '../history/history_page.dart';
import '../settings_page.dart';
import '../mobile/widgets/page_base.dart';
import '../home_page/home_page.dart';

class PageBranch extends ConsumerWidget {
const PageBranch({
super.key,
required this.pageIndex,
});

final int pageIndex;
@override
Widget build(BuildContext context, WidgetRef ref) {
if (context.isMediumWindow) {
switch (pageIndex) {
case 1:
return const EnvironmentPage();
case 2:
return const HistoryPage();
case 3:
return const PageBase(
title: 'Settings',
scaffoldBody: SettingsPage(),
);
default:
return const RequestResponsePage();
}
} else {
switch (pageIndex) {
case 0:
return const HomePage();
case 1:
return const EnvironmentPage();
case 2:
return const HistoryPage();
case 3:
return const SettingsPage();
default:
return const HomePage();
}

}
}
}
17 changes: 5 additions & 12 deletions lib/screens/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import 'package:apidash/widgets/widgets.dart';
import 'package:apidash/consts.dart';
import 'package:apidash/dashbot/dashbot.dart';
import 'common_widgets/common_widgets.dart';
import 'envvar/environment_page.dart';
import 'home_page/home_page.dart';
import 'history/history_page.dart';
import 'settings_page.dart';

class Dashboard extends ConsumerWidget {
const Dashboard({super.key});
Expand Down Expand Up @@ -112,14 +108,11 @@ class Dashboard extends ConsumerWidget {
color: Theme.of(context).colorScheme.surfaceContainerHigh,
),
Expanded(
child: IndexedStack(
alignment: AlignmentDirectional.topCenter,
index: railIdx,
children: const [
HomePage(),
EnvironmentPage(),
HistoryPage(),
SettingsPage(),
child: Stack(
children: [
PageBranch(
pageIndex: railIdx,
),
],
),
)
Expand Down
31 changes: 1 addition & 30 deletions lib/screens/mobile/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flex_color_scheme/flex_color_scheme.dart';
import 'package:apidash/providers/providers.dart';
import 'requests_page/requests_page.dart';
import '../envvar/environment_page.dart';
import '../history/history_page.dart';
import '../settings_page.dart';
import 'widgets/page_base.dart';
import 'navbar.dart';
import '../common_widgets/common_widgets.dart';

class MobileDashboard extends ConsumerStatefulWidget {
const MobileDashboard({super.key});
Expand Down Expand Up @@ -57,28 +53,3 @@ class _MobileDashboardState extends ConsumerState<MobileDashboard> {
);
}
}

class PageBranch extends ConsumerWidget {
const PageBranch({
super.key,
required this.pageIndex,
});

final int pageIndex;
@override
Widget build(BuildContext context, WidgetRef ref) {
switch (pageIndex) {
case 1:
return const EnvironmentPage();
case 2:
return const HistoryPage();
case 3:
return const PageBase(
title: 'Settings',
scaffoldBody: SettingsPage(),
);
default:
return const RequestResponsePage();
}
}
}