Merge branch 'main' into add-feature-history

This commit is contained in:
Ragul Raj
2024-07-13 17:44:25 +05:30
committed by GitHub
11 changed files with 86 additions and 70 deletions

View File

@ -2,6 +2,7 @@ import 'package:apidash/screens/about_dialog.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:apidash/providers/providers.dart';
import 'package:apidash/widgets/widgets.dart';
import 'package:apidash/consts.dart';
import 'common_widgets/common_widgets.dart';
import 'envvar/environment_page.dart';

View File

@ -72,6 +72,12 @@ class PageBranch extends ConsumerWidget {
return EnvironmentPage(
scaffoldKey: scaffoldKey,
);
// case 2:
// // TODO: Implement history page
// return const PageBase(
// title: 'History',
// scaffoldBody: SizedBox(),
// );
case 2:
// TODO: Implement history page
return const PageBase(

View File

@ -57,6 +57,15 @@ class BottomNavBar extends ConsumerWidget {
label: 'History',
),
),
// Expanded(
// child: NavbarButton(
// railIdx: railIdx,
// buttonIdx: 2,
// selectedIcon: Icons.history,
// icon: Icons.history_outlined,
// label: 'History',
// ),
// ),
Expanded(
child: NavbarButton(
railIdx: railIdx,

View File

@ -0,0 +1,29 @@
import 'package:apidash/consts.dart';
import 'package:flutter/material.dart';
import 'package:apidash/widgets/widgets.dart';
showAboutAppDialog(
BuildContext context,
) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
contentPadding: kPt20 + kPh20 + kPb10,
content: Container(
width: double.infinity,
height: double.infinity,
constraints: const BoxConstraints(maxWidth: 540, maxHeight: 544),
child: const IntroMessage(),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text("Close"),
),
],
);
});
}

View File

@ -19,8 +19,8 @@ class DashboardSplitView extends StatefulWidget {
class DashboardSplitViewState extends State<DashboardSplitView> {
final MultiSplitViewController _controller = MultiSplitViewController(
areas: [
Area(id: "sidebar", size: 250, min: 200),
Area(id: "main", min: 0.7),
Area(id: "sidebar", min: 220, size: 250, max: 350),
Area(id: "main", min: 400),
],
);
@ -44,6 +44,8 @@ class DashboardSplitViewState extends State<DashboardSplitView> {
),
child: MultiSplitView(
controller: _controller,
sizeOverflowPolicy: SizeOverflowPolicy.shrinkFirst,
sizeUnderflowPolicy: SizeUnderflowPolicy.stretchLast,
builder: (context, area) {
return switch (area.id) {
"sidebar" => widget.sidebarWidget,

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:multi_split_view/multi_split_view.dart';
import 'package:apidash/consts.dart';
class EqualSplitView extends StatefulWidget {
class EqualSplitView extends StatelessWidget {
const EqualSplitView({
super.key,
required this.leftWidget,
@ -12,17 +12,17 @@ class EqualSplitView extends StatefulWidget {
final Widget leftWidget;
final Widget rightWidget;
@override
State<EqualSplitView> createState() => _EqualSplitViewState();
}
class _EqualSplitViewState extends State<EqualSplitView> {
final MultiSplitViewController _controller = MultiSplitViewController(
areas: [
Area(id: "left", min: kMinRequestEditorDetailsCardPaneSize),
Area(id: "right", min: kMinRequestEditorDetailsCardPaneSize),
],
);
getMinFractionWidth(double width) {
if (width < 900) {
return 0.9;
} else if (width < 1000) {
return 0.7;
} else if (width < 1200) {
return 0.5;
} else {
return 0.4;
}
}
@override
Widget build(BuildContext context) {
@ -37,22 +37,26 @@ class _EqualSplitViewState extends State<EqualSplitView> {
animationEnabled: false,
),
),
child: MultiSplitView(
controller: _controller,
builder: (context, area) {
return switch (area.id) {
"left" => widget.leftWidget,
"right" => widget.rightWidget,
_ => Container(),
};
child: LayoutBuilder(
builder: (context, constraints) {
final minWidth = getMinFractionWidth(constraints.maxWidth);
return MultiSplitView(
controller: MultiSplitViewController(
areas: [
Area(id: "left", flex: 1, min: minWidth),
Area(id: "right", flex: 1, min: minWidth),
],
),
builder: (context, area) {
return switch (area.id) {
"left" => leftWidget,
"right" => rightWidget,
_ => Container(),
};
},
);
},
),
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
}

View File

@ -10,7 +10,8 @@ export 'card_sidebar_request.dart';
export 'checkbox.dart';
export 'code_previewer.dart';
export 'codegen_previewer.dart';
export 'dialogs.dart';
export 'dialog_about.dart';
export 'dialog_rename.dart';
export 'dropdown_codegen.dart';
export 'dropdown_content_type.dart';
export 'dropdown_formdata.dart';

View File

@ -861,10 +861,10 @@ packages:
dependency: "direct main"
description:
name: multi_split_view
sha256: "2ef6a7ff9d0957bf559075d2703507ea898c8b70e37ff5ac3636298370513b7a"
sha256: "1ee1974d9aae6bdc08e2abdead6066c914cefe4b0c5999cac1a2e4722fcf33ba"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
version: "3.2.2"
nested:
dependency: transitive
description:

View File

@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
multi_split_view: ^3.2.1
multi_split_view: ^3.2.2
url_launcher: ^6.2.5
flutter_riverpod: ^2.5.1
riverpod: ^2.5.1

View File

@ -57,7 +57,6 @@ void main() {
// Verify that the HomePage is displayed initially
expect(find.byType(HomePage), findsOneWidget);
expect(find.byType(EnvironmentPage), findsNothing);
// expect(find.byType(IntroPage), findsNothing);
expect(find.byType(SettingsPage), findsNothing);
});
@ -78,33 +77,9 @@ void main() {
// Verify that the EnvironmentPage is displayed
expect(find.byType(HomePage), findsNothing);
expect(find.byType(EnvironmentPage), findsOneWidget);
// expect(find.byType(IntroPage), findsNothing);
expect(find.byType(SettingsPage), findsNothing);
});
// testWidgets(
// "Dashboard should display IntroPage when navRailIndexStateProvider is 2",
// (WidgetTester tester) async {
// await tester.pumpWidget(
// ProviderScope(
// overrides: [
// navRailIndexStateProvider.overrideWith((ref) => 2),
// ],
// child: const Portal(
// child: MaterialApp(
// home: Dashboard(),
// ),
// ),
// ),
// );
// // Verify that the IntroPage is displayed
// expect(find.byType(HomePage), findsNothing);
// expect(find.byType(EnvironmentPage), findsNothing);
// expect(find.byType(IntroPage), findsOneWidget);
// expect(find.byType(SettingsPage), findsNothing);
// });
testWidgets(
"Dashboard should display SettingsPage when navRailIndexStateProvider is 3",
(WidgetTester tester) async {
@ -124,7 +99,6 @@ void main() {
// Verify that the SettingsPage is displayed
expect(find.byType(HomePage), findsNothing);
expect(find.byType(EnvironmentPage), findsNothing);
// expect(find.byType(IntroPage), findsNothing);
expect(find.byType(SettingsPage), findsOneWidget);
});
@ -183,11 +157,10 @@ void main() {
// Verify that the navRailIndexStateProvider still has the updated value
final dashboard = tester.element(find.byType(Dashboard));
final container = ProviderScope.containerOf(dashboard);
expect(container.read(navRailIndexStateProvider), 3);
expect(container.read(navRailIndexStateProvider), 2);
// Verify that the SettingsPage is still displayed after the rebuild
expect(find.byType(SettingsPage), findsOneWidget);
// expect(find.byType(IntroPage), findsNothing);
expect(find.byType(HomePage), findsNothing);
expect(find.byType(EnvironmentPage), findsNothing);
});
@ -218,17 +191,8 @@ void main() {
// Verify that the selected icon is the filled version (selectedIcon)
expect(find.byIcon(Icons.computer_rounded), findsOneWidget);
// // Go to IntroPage
// container.read(navRailIndexStateProvider.notifier).state = 2;
// await tester.pump();
// // Verify that the IntroPage is displayed
// expect(find.byType(IntroPage), findsOneWidget);
// // Verify that the selected icon is the filled version (selectedIcon)
// expect(find.byIcon(Icons.help), findsOneWidget);
// Go to SettingsPage
container.read(navRailIndexStateProvider.notifier).state = 3;
container.read(navRailIndexStateProvider.notifier).state = 2;
await tester.pump();
// Verify that the SettingsPage is displayed