Skip to content

Commit

Permalink
ui improve for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Predidit committed May 4, 2024
1 parent 9d57090 commit 208c5db
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:window_manager/window_manager.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isWindows) {
if (Platform.isWindows || Platform.isLinux) {
await windowManager.ensureInitialized();
WindowOptions windowOptions = const WindowOptions(
size: Size(1280, 830),
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/card/bangumi_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
Widget build(BuildContext context) {
return Column(
children: [
Platform.isWindows
Platform.isWindows || Platform.isLinux
? Column(
children: [
const SizedBox(height: 7),
Expand Down Expand Up @@ -112,12 +112,12 @@ class _BangumiPanelState extends State<BangumiPanel> {
),
),
SizedBox(
height: Platform.isWindows ? 72 : 400,
height: Platform.isWindows || Platform.isLinux ? 72 : 400,
child: GridView.builder(
controller: listViewScrollCtr,
scrollDirection: Axis.vertical, // 将滚动方向改为竖直
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: Platform.isWindows ? 10 : 3,
crossAxisCount: Platform.isWindows || Platform.isLinux ? 10 : 3,
crossAxisSpacing: 10, // 间距
mainAxisSpacing: 5, // 间距
childAspectRatio: 1.7, // 子项宽高比
Expand Down
10 changes: 8 additions & 2 deletions lib/pages/my/my_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:bilineo/pages/my/my_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
Expand Down Expand Up @@ -70,8 +72,12 @@ class _MyPageState extends State<MyPage> {
const SizedBox(height: 5),
GestureDetector(
onTap: () {
navigationBarState.hideNavigate();
_mineController.onLogin();
if (!Platform.isLinux) {
navigationBarState.hideNavigate();
_mineController.onLogin();
} else {
SmartDialog.showToast('Linux版本账号功能施工中');
}
},
child: ClipOval(
child: Container(
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/player/player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ abstract class _PlayerController with Store {
}

Future<void> enterFullScreen() async {
if (Platform.isWindows) {
if (Platform.isWindows || Platform.isLinux) {
await windowManager.setFullScreen(true);
return;
}
Expand Down Expand Up @@ -502,7 +502,7 @@ abstract class _PlayerController with Store {
//退出全屏显示
Future<void> exitFullScreen() async {
debugPrint('退出全屏模式');
if (Platform.isWindows) {
if (Platform.isWindows || Platform.isLinux) {
await windowManager.setFullScreen(false);
}
dynamic document;
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/player/player_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class _PlayerItemState extends State<PlayerItem> {
// const Text('Video Player Test'),
Observer(builder: (context) {
return SizedBox(
width: Platform.isWindows
width: Platform.isWindows || Platform.isLinux
? MediaQuery.of(context).size.width
: ((!videoPageController.androidFullscreen) ? MediaQuery.of(context).size.width : (MediaQuery.of(context).size.height * 16.0 / 9.0)),
height: Platform.isWindows
height: Platform.isWindows || Platform.isLinux
? (MediaQuery.of(context).size.width * 9.0 / (16.0))
: ((!videoPageController.androidFullscreen) ? MediaQuery.of(context).size.width * 9.0 / 16.0 : MediaQuery.of(context).size.height),
child: playerController.dataStatus == 'loaded'
Expand Down Expand Up @@ -77,10 +77,10 @@ class _PlayerItemState extends State<PlayerItem> {
child: Center(
child: CircularProgressIndicator(),
),
height: Platform.isWindows
height: Platform.isWindows || Platform.isLinux
? MediaQuery.of(context).size.width * 9.0 / 32.0
: MediaQuery.of(context).size.width * 9.0 / 16.0,
width: Platform.isWindows
width: Platform.isWindows || Platform.isLinux
? MediaQuery.of(context).size.width / 2
: MediaQuery.of(context).size.width,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/popular/popular_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class _PopularPageState extends State<PopularPage>
}

Widget contentGrid(bangumiList) {
int crossCount = Platform.isWindows ? 6 : 3;
int crossCount = Platform.isWindows || Platform.isLinux ? 6 : 3;
return SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// 行间距
Expand Down
1 change: 0 additions & 1 deletion lib/pages/webview_desktop/webview_desktop_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:webview_windows/webview_windows.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
Expand Down
4 changes: 4 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <media_kit_video/media_kit_video_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
#include <webview_universal/webview_universal_plugin.h>
#include <window_manager/window_manager_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
Expand All @@ -29,6 +30,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
g_autoptr(FlPluginRegistrar) webview_universal_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "WebviewUniversalPlugin");
webview_universal_plugin_register_with_registrar(webview_universal_registrar);
g_autoptr(FlPluginRegistrar) window_manager_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin");
window_manager_plugin_register_with_registrar(window_manager_registrar);
Expand Down
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
media_kit_video
screen_retriever
url_launcher_linux
webview_universal
window_manager
)

Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import shared_preferences_foundation
import sqflite
import url_launcher_macos
import wakelock_plus
import webview_universal
import window_manager

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
Expand All @@ -34,5 +35,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
WebviewUniversalPlugin.register(with: registry.registrar(forPlugin: "WebviewUniversalPlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
}
16 changes: 16 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.10.0"
webview_flutter_web:
dependency: transitive
description:
name: webview_flutter_web
sha256: "7f7cb8cfe5a5dee3b55d660a367c00838be56540ccb4097e84601bb6cb354af3"
url: "https://pub.dev"
source: hosted
version: "0.2.2+4"
webview_flutter_wkwebview:
dependency: transitive
description:
Expand All @@ -1395,6 +1403,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.13.0"
webview_universal:
dependency: "direct main"
description:
name: webview_universal
sha256: "0ee988cb654a64a53edf5f62a0c41777a0f5af2eabf299226ff2dc5b6de3cba8"
url: "https://pub.dev"
source: hosted
version: "0.0.5"
webview_windows:
dependency: "direct main"
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ dependencies:
git:
url: https://github.com/Predidit/flutter-webview-windows.git
ref: main
webview_universal: ^0.0.5

dev_dependencies:
flutter_test:
Expand Down
3 changes: 3 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <screen_brightness_windows/screen_brightness_windows_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
#include <webview_universal/webview_universal_plugin.h>
#include <webview_windows/webview_windows_plugin.h>
#include <window_manager/window_manager_plugin.h>

Expand All @@ -31,6 +32,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
WebviewUniversalPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("WebviewUniversalPlugin"));
WebviewWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("WebviewWindowsPlugin"));
WindowManagerPluginRegisterWithRegistrar(
Expand Down
1 change: 1 addition & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
screen_brightness_windows
screen_retriever
url_launcher_windows
webview_universal
webview_windows
window_manager
)
Expand Down

0 comments on commit 208c5db

Please sign in to comment.