mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Merge branch 'main' into add-feature-history
This commit is contained in:
@ -2,6 +2,7 @@ import 'package:apidash/screens/about_dialog.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:apidash/providers/providers.dart';
|
import 'package:apidash/providers/providers.dart';
|
||||||
|
import 'package:apidash/widgets/widgets.dart';
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/consts.dart';
|
||||||
import 'common_widgets/common_widgets.dart';
|
import 'common_widgets/common_widgets.dart';
|
||||||
import 'envvar/environment_page.dart';
|
import 'envvar/environment_page.dart';
|
||||||
|
@ -72,6 +72,12 @@ class PageBranch extends ConsumerWidget {
|
|||||||
return EnvironmentPage(
|
return EnvironmentPage(
|
||||||
scaffoldKey: scaffoldKey,
|
scaffoldKey: scaffoldKey,
|
||||||
);
|
);
|
||||||
|
// case 2:
|
||||||
|
// // TODO: Implement history page
|
||||||
|
// return const PageBase(
|
||||||
|
// title: 'History',
|
||||||
|
// scaffoldBody: SizedBox(),
|
||||||
|
// );
|
||||||
case 2:
|
case 2:
|
||||||
// TODO: Implement history page
|
// TODO: Implement history page
|
||||||
return const PageBase(
|
return const PageBase(
|
||||||
|
@ -57,6 +57,15 @@ class BottomNavBar extends ConsumerWidget {
|
|||||||
label: 'History',
|
label: 'History',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// Expanded(
|
||||||
|
// child: NavbarButton(
|
||||||
|
// railIdx: railIdx,
|
||||||
|
// buttonIdx: 2,
|
||||||
|
// selectedIcon: Icons.history,
|
||||||
|
// icon: Icons.history_outlined,
|
||||||
|
// label: 'History',
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: NavbarButton(
|
child: NavbarButton(
|
||||||
railIdx: railIdx,
|
railIdx: railIdx,
|
||||||
|
29
lib/widgets/dialog_about.dart
Normal file
29
lib/widgets/dialog_about.dart
Normal 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"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
@ -19,8 +19,8 @@ class DashboardSplitView extends StatefulWidget {
|
|||||||
class DashboardSplitViewState extends State<DashboardSplitView> {
|
class DashboardSplitViewState extends State<DashboardSplitView> {
|
||||||
final MultiSplitViewController _controller = MultiSplitViewController(
|
final MultiSplitViewController _controller = MultiSplitViewController(
|
||||||
areas: [
|
areas: [
|
||||||
Area(id: "sidebar", size: 250, min: 200),
|
Area(id: "sidebar", min: 220, size: 250, max: 350),
|
||||||
Area(id: "main", min: 0.7),
|
Area(id: "main", min: 400),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -44,6 +44,8 @@ class DashboardSplitViewState extends State<DashboardSplitView> {
|
|||||||
),
|
),
|
||||||
child: MultiSplitView(
|
child: MultiSplitView(
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
|
sizeOverflowPolicy: SizeOverflowPolicy.shrinkFirst,
|
||||||
|
sizeUnderflowPolicy: SizeUnderflowPolicy.stretchLast,
|
||||||
builder: (context, area) {
|
builder: (context, area) {
|
||||||
return switch (area.id) {
|
return switch (area.id) {
|
||||||
"sidebar" => widget.sidebarWidget,
|
"sidebar" => widget.sidebarWidget,
|
||||||
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:multi_split_view/multi_split_view.dart';
|
import 'package:multi_split_view/multi_split_view.dart';
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/consts.dart';
|
||||||
|
|
||||||
class EqualSplitView extends StatefulWidget {
|
class EqualSplitView extends StatelessWidget {
|
||||||
const EqualSplitView({
|
const EqualSplitView({
|
||||||
super.key,
|
super.key,
|
||||||
required this.leftWidget,
|
required this.leftWidget,
|
||||||
@ -12,17 +12,17 @@ class EqualSplitView extends StatefulWidget {
|
|||||||
final Widget leftWidget;
|
final Widget leftWidget;
|
||||||
final Widget rightWidget;
|
final Widget rightWidget;
|
||||||
|
|
||||||
@override
|
getMinFractionWidth(double width) {
|
||||||
State<EqualSplitView> createState() => _EqualSplitViewState();
|
if (width < 900) {
|
||||||
}
|
return 0.9;
|
||||||
|
} else if (width < 1000) {
|
||||||
class _EqualSplitViewState extends State<EqualSplitView> {
|
return 0.7;
|
||||||
final MultiSplitViewController _controller = MultiSplitViewController(
|
} else if (width < 1200) {
|
||||||
areas: [
|
return 0.5;
|
||||||
Area(id: "left", min: kMinRequestEditorDetailsCardPaneSize),
|
} else {
|
||||||
Area(id: "right", min: kMinRequestEditorDetailsCardPaneSize),
|
return 0.4;
|
||||||
],
|
}
|
||||||
);
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -37,22 +37,26 @@ class _EqualSplitViewState extends State<EqualSplitView> {
|
|||||||
animationEnabled: false,
|
animationEnabled: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: MultiSplitView(
|
child: LayoutBuilder(
|
||||||
controller: _controller,
|
builder: (context, constraints) {
|
||||||
builder: (context, area) {
|
final minWidth = getMinFractionWidth(constraints.maxWidth);
|
||||||
return switch (area.id) {
|
return MultiSplitView(
|
||||||
"left" => widget.leftWidget,
|
controller: MultiSplitViewController(
|
||||||
"right" => widget.rightWidget,
|
areas: [
|
||||||
_ => Container(),
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ export 'card_sidebar_request.dart';
|
|||||||
export 'checkbox.dart';
|
export 'checkbox.dart';
|
||||||
export 'code_previewer.dart';
|
export 'code_previewer.dart';
|
||||||
export 'codegen_previewer.dart';
|
export 'codegen_previewer.dart';
|
||||||
export 'dialogs.dart';
|
export 'dialog_about.dart';
|
||||||
|
export 'dialog_rename.dart';
|
||||||
export 'dropdown_codegen.dart';
|
export 'dropdown_codegen.dart';
|
||||||
export 'dropdown_content_type.dart';
|
export 'dropdown_content_type.dart';
|
||||||
export 'dropdown_formdata.dart';
|
export 'dropdown_formdata.dart';
|
||||||
|
@ -861,10 +861,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: multi_split_view
|
name: multi_split_view
|
||||||
sha256: "2ef6a7ff9d0957bf559075d2703507ea898c8b70e37ff5ac3636298370513b7a"
|
sha256: "1ee1974d9aae6bdc08e2abdead6066c914cefe4b0c5999cac1a2e4722fcf33ba"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.2.1"
|
version: "3.2.2"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -10,7 +10,7 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
multi_split_view: ^3.2.1
|
multi_split_view: ^3.2.2
|
||||||
url_launcher: ^6.2.5
|
url_launcher: ^6.2.5
|
||||||
flutter_riverpod: ^2.5.1
|
flutter_riverpod: ^2.5.1
|
||||||
riverpod: ^2.5.1
|
riverpod: ^2.5.1
|
||||||
|
@ -57,7 +57,6 @@ void main() {
|
|||||||
// Verify that the HomePage is displayed initially
|
// Verify that the HomePage is displayed initially
|
||||||
expect(find.byType(HomePage), findsOneWidget);
|
expect(find.byType(HomePage), findsOneWidget);
|
||||||
expect(find.byType(EnvironmentPage), findsNothing);
|
expect(find.byType(EnvironmentPage), findsNothing);
|
||||||
// expect(find.byType(IntroPage), findsNothing);
|
|
||||||
expect(find.byType(SettingsPage), findsNothing);
|
expect(find.byType(SettingsPage), findsNothing);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -78,33 +77,9 @@ void main() {
|
|||||||
// Verify that the EnvironmentPage is displayed
|
// Verify that the EnvironmentPage is displayed
|
||||||
expect(find.byType(HomePage), findsNothing);
|
expect(find.byType(HomePage), findsNothing);
|
||||||
expect(find.byType(EnvironmentPage), findsOneWidget);
|
expect(find.byType(EnvironmentPage), findsOneWidget);
|
||||||
// expect(find.byType(IntroPage), findsNothing);
|
|
||||||
expect(find.byType(SettingsPage), 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(
|
testWidgets(
|
||||||
"Dashboard should display SettingsPage when navRailIndexStateProvider is 3",
|
"Dashboard should display SettingsPage when navRailIndexStateProvider is 3",
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
@ -124,7 +99,6 @@ void main() {
|
|||||||
// Verify that the SettingsPage is displayed
|
// Verify that the SettingsPage is displayed
|
||||||
expect(find.byType(HomePage), findsNothing);
|
expect(find.byType(HomePage), findsNothing);
|
||||||
expect(find.byType(EnvironmentPage), findsNothing);
|
expect(find.byType(EnvironmentPage), findsNothing);
|
||||||
// expect(find.byType(IntroPage), findsNothing);
|
|
||||||
expect(find.byType(SettingsPage), findsOneWidget);
|
expect(find.byType(SettingsPage), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -183,11 +157,10 @@ void main() {
|
|||||||
// Verify that the navRailIndexStateProvider still has the updated value
|
// Verify that the navRailIndexStateProvider still has the updated value
|
||||||
final dashboard = tester.element(find.byType(Dashboard));
|
final dashboard = tester.element(find.byType(Dashboard));
|
||||||
final container = ProviderScope.containerOf(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
|
// Verify that the SettingsPage is still displayed after the rebuild
|
||||||
expect(find.byType(SettingsPage), findsOneWidget);
|
expect(find.byType(SettingsPage), findsOneWidget);
|
||||||
// expect(find.byType(IntroPage), findsNothing);
|
|
||||||
expect(find.byType(HomePage), findsNothing);
|
expect(find.byType(HomePage), findsNothing);
|
||||||
expect(find.byType(EnvironmentPage), findsNothing);
|
expect(find.byType(EnvironmentPage), findsNothing);
|
||||||
});
|
});
|
||||||
@ -218,17 +191,8 @@ void main() {
|
|||||||
// Verify that the selected icon is the filled version (selectedIcon)
|
// Verify that the selected icon is the filled version (selectedIcon)
|
||||||
expect(find.byIcon(Icons.computer_rounded), findsOneWidget);
|
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
|
// Go to SettingsPage
|
||||||
container.read(navRailIndexStateProvider.notifier).state = 3;
|
container.read(navRailIndexStateProvider.notifier).state = 2;
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
// Verify that the SettingsPage is displayed
|
// Verify that the SettingsPage is displayed
|
||||||
|
Reference in New Issue
Block a user