Skip to content
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

[Pull Request] Crequency/KitX#278 #2

Merged
merged 13 commits into from
Feb 25, 2024
Merged
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Ignore Visual Studio temporary files, build results, and
## Ignore Platform Files
*.DS_Store


## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
Expand Down
Empty file modified KitX Website Flutter/kitx_website/build.sh
100644 → 100755
Empty file.
Empty file modified KitX Website Flutter/kitx_website/deploy.sh
100644 → 100755
Empty file.
9 changes: 4 additions & 5 deletions KitX Website Flutter/kitx_website/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'dart:ui' as ui;

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'package:kitx_website/pages/home_page.dart';
import 'package:kitx_website/pages/navigation_page.dart';

import 'package:kitx_website/themes/light_theme.dart';
import 'package:kitx_website/themes/dark_theme.dart';
Expand Down Expand Up @@ -31,9 +30,9 @@ class MainApp extends StatelessWidget {
darkTheme: darkThemeData,
debugShowCheckedModeBanner: false,
translations: Translation(),
locale: ui.window.locale,
locale: PlatformDispatcher.instance.locale,
fallbackLocale: Locale('en', 'US'),
home: const HomePage(),
home: const NavigationPage(),
),
);
}
Expand Down
46 changes: 21 additions & 25 deletions KitX Website Flutter/kitx_website/lib/pages/controls/drawer.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:community_material_icon/community_material_icon.dart';
import 'package:kitx_website/utils/global.dart';
import 'package:kitx_website/utils/open_link.dart';

class AppDrawer extends StatelessWidget {
Expand All @@ -14,43 +15,38 @@ class AppDrawer extends StatelessWidget {
children: <Widget>[
ListTile(title: const Text(' ')),
ListTile(
leading: Icon(Icons.home),
leading: const Icon(Icons.home),
title: Text('Home_Page'.tr),
onTap: () => openLink('Home_Page'),
onTap: () => Global.navPageTo(0),
),
ListTile(
leading: Icon(Icons.account_balance_rounded),
leading: const Icon(Icons.account_balance_rounded),
title: Text('Plugins_Page'.tr),
onTap: () {},
onTap: () => Global.navPageTo(1),
),
ListTile(
leading: Icon(CommunityMaterialIcons.file_document),
leading: const Icon(CommunityMaterialIcons.file_document),
title: Text('Public_Docs'.tr),
onTap: () => openLink('Docs_KitX'),
onTap: () => Global.navPageTo(2),
),
ListTile(
leading: const Icon(Icons.settings),
title: Text('Settings_Page'.tr),
onTap: () => Global.navPageTo(3),
),
Divider(),
ListTile(
leading: Icon(CommunityMaterialIcons.github),
leading: const Icon(CommunityMaterialIcons.github),
title: const Text('GitHub'),
trailing: const Icon(Icons.open_in_new),
onTap: () => openLink('GitHubRepo_KitX'),
),
// DrawerHeader(
// decoration: BoxDecoration(
// // color: Colors.blue,
// image: const DecorationImage(
// alignment: Alignment.topCenter,
// image: AssetImage('assets/KitX-Background.png'),
// fit: BoxFit.cover,
// ),
// ),
// child: Text(
// '',
// // 'Drawer_Title'.tr,
// style: TextStyle(
// color: Colors.white,
// fontSize: 24,
// ),
// ),
// ),
ListTile(
leading: const Icon(CommunityMaterialIcons.file_document),
title: Text('Public_Docs'.tr),
trailing: const Icon(Icons.open_in_new),
onTap: () => openLink('Docs_KitX'),
),
],
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,28 @@ var kitx_github_repo_key = 'GitHubRepo_KitX';

List<Widget> getActions(BuildContext context) => [
IconButton(
onPressed: () => openLink(kitx_github_repo_key),
onPressed: () => openLink(kitx_github_repo_key),
icon: Container(
margin: EdgeInsets.fromLTRB(0, 0, 0, 1),
child: Icon(CommunityMaterialIcons.github),
),
tooltip: 'GitHub'),
SizedBox(width: actionsPadding),
IconButton(
onPressed: () => openLink(kitx_docs_key),
icon: Container(
margin: EdgeInsets.fromLTRB(0, 0, 0, 1),
child: Icon(CommunityMaterialIcons.github),
child: Icon(CommunityMaterialIcons.file_document),
),
tooltip: 'Public_Docs'.tr,
),
SizedBox(width: actionsPadding),
Obx(
() => IconButton(
onPressed: () => Global.themeNotifier.value = context.isDarkMode ? ThemeMode.light : ThemeMode.dark,
icon: themeButtonInLightMode.value ? const Icon(Icons.light_mode) : const Icon(Icons.dark_mode),
onPressed: () => Global.themeNotifier.value =
context.isDarkMode ? ThemeMode.light : ThemeMode.dark,
icon: themeButtonInLightMode.value
? const Icon(Icons.light_mode)
: const Icon(Icons.dark_mode),
),
),
SizedBox(width: actionsPadding),
Expand All @@ -37,11 +48,13 @@ List<Widget> getActions(BuildContext context) => [
itemBuilder: (context) => [
PopupMenuItem(
child: const Text('简体中文'),
onTap: () => Global.delay(() => Get.updateLocale(Locale('zh', 'CN')), 200),
onTap: () =>
Global.delay(() => Get.updateLocale(Locale('zh', 'CN')), 200),
),
PopupMenuItem(
child: const Text('English (US)'),
onTap: () => Global.delay(() => Get.updateLocale(Locale('en', 'US')), 200),
onTap: () =>
Global.delay(() => Get.updateLocale(Locale('en', 'US')), 200),
),
],
),
Expand Down
75 changes: 75 additions & 0 deletions KitX Website Flutter/kitx_website/lib/pages/docs_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'dart:html';
import 'dart:ui_web';

import 'package:flutter/material.dart';
import 'package:kitx_website/utils/global.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';

class DocsPage extends StatefulWidget {
const DocsPage({super.key});

@override
_DocsPageState createState() => _DocsPageState();
}

class _DocsPageState extends State<DocsPage> {
@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
platformViewRegistry.registerViewFactory('iframe-webview', (_) {
return IFrameElement()
..style.height = '100%'
..style.width = '100%'
..src = 'https://kitx.docs.catrol.cn/'
..style.border = 'none';
});

const actionsPadding = SizedBox(width: 8.0);

return Scaffold(
appBar: AppBar(
title: Text('Docs Inside'),
actions: [
IconButton(
icon: const Icon(Icons.home),
onPressed: () => Global.navPageTo(0),
),
actionsPadding,
IconButton(
icon: const Icon(Icons.account_balance_rounded),
onPressed: () => Global.navPageTo(1),
),
actionsPadding,
IconButton(
icon: const Icon(Icons.open_in_new),
onPressed: () {
window.open('https://kitx.docs.catrol.cn/', 'KitX Docs');
},
),
actionsPadding,
],
),
drawerEnableOpenDragGesture: false,
body: Stack(children: [
Center(
child: LoadingAnimationWidget.staggeredDotsWave(
color: Colors.white,
size: 200,
),
),
SizedBox(
width: double.infinity,
height: double.infinity,
child: HtmlElementView(
viewType: 'iframe-webview',
onPlatformViewCreated: (int id) {},
),
),
]),
);
}
}
7 changes: 5 additions & 2 deletions KitX Website Flutter/kitx_website/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class _HomePageState extends State<HomePage> {
if (width != null) {
if (width <= 500 && showTextOfLinkButton.value)
showTextOfLinkButton.value = false;
else if (width > 500 && !showTextOfLinkButton.value) showTextOfLinkButton.value = true;
else if (width > 500 && !showTextOfLinkButton.value)
showTextOfLinkButton.value = true;
}
}

Expand All @@ -42,7 +43,9 @@ class _HomePageState extends State<HomePage> {
title: Obx(
() => Text(
showTextOfLinkButton.value ? 'KitX Website' : 'KitX',
overflow: showTextOfLinkButton.value ? TextOverflow.fade : TextOverflow.ellipsis,
overflow: showTextOfLinkButton.value
? TextOverflow.fade
: TextOverflow.ellipsis,
),
),
actions: getActions(context),
Expand Down
98 changes: 98 additions & 0 deletions KitX Website Flutter/kitx_website/lib/pages/navigation_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import 'package:community_material_icon/community_material_icon.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:kitx_website/pages/docs_page.dart';
import 'package:kitx_website/pages/home_page.dart';
import 'package:kitx_website/pages/plugins_page.dart';
import 'package:kitx_website/pages/settings_page.dart';
import 'package:kitx_website/utils/global.dart';

class NavigationPage extends StatefulWidget {
const NavigationPage({super.key});

@override
State<NavigationPage> createState() => _NavigationPageState();
}

class _NavigationPageState extends State<NavigationPage> {
double _buttonsPadding = 10;
var _pageController = PageController(initialPage: 0);

@override
void initState() {
super.initState();
Global.navPageController = _pageController;
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
children: <Widget>[
MediaQuery.of(context).size.width > MediaQuery.of(context).size.height
? Obx(
() => NavigationRail(
selectedIndex: Global.navigationIndex.value,
groupAlignment: -1.0,
onDestinationSelected: (index) => Global.navPageTo(index),
useIndicator: true,
labelType: NavigationRailLabelType.all,
leading: FloatingActionButton(
elevation: 0,
onPressed: () {},
child: const Icon(Icons.search),
),
destinations: <NavigationRailDestination>[
NavigationRailDestination(
icon: const Icon(Icons.home),
selectedIcon: const Icon(Icons.home_outlined),
label: Text('Home_Page'.tr),
padding:
EdgeInsets.symmetric(vertical: _buttonsPadding),
),
NavigationRailDestination(
icon: const Icon(CommunityMaterialIcons.cube),
selectedIcon:
const Icon(CommunityMaterialIcons.cube_outline),
label: Text('Plugins_Page'.tr),
padding:
EdgeInsets.symmetric(vertical: _buttonsPadding),
),
NavigationRailDestination(
icon: const Icon(Icons.account_balance),
selectedIcon:
const Icon(Icons.account_balance_outlined),
label: Text('Public_Docs'.tr),
padding:
EdgeInsets.symmetric(vertical: _buttonsPadding),
),
NavigationRailDestination(
icon: const Icon(Icons.settings),
selectedIcon: const Icon(Icons.settings_outlined),
label: Text('Settings_Page'.tr),
padding:
EdgeInsets.symmetric(vertical: _buttonsPadding),
),
],
),
)
: const SizedBox(),
const VerticalDivider(thickness: 1, width: 1),
Expanded(
child: PageView(
children: const [
const ClipRect(child: const HomePage()),
const ClipRect(child: const PluginsPage()),
const ClipRect(child: const DocsPage()),
const ClipRect(child: const SettingsPage()),
],
controller: _pageController,
physics: const NeverScrollableScrollPhysics(),
scrollDirection: Axis.vertical,
),
),
],
),
);
}
}
31 changes: 31 additions & 0 deletions KitX Website Flutter/kitx_website/lib/pages/plugins_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'dart:html';

import 'package:flutter/material.dart';
import 'package:kitx_website/pages/controls/drawer.dart';

class PluginsPage extends StatefulWidget {
const PluginsPage({super.key});

@override
_PluginsPageState createState() => _PluginsPageState();
}

class _PluginsPageState extends State<PluginsPage> {
@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('PluginsPage'),
),
drawer: AppDrawer(),
drawerEnableOpenDragGesture: true,
drawerEdgeDragWidth: (window.innerWidth ?? 300) / 2 + 50,
body: Center(child: Text('Under developing ...')),
);
}
}
Loading