Skip to content

Commit

Permalink
added screen size and style to go into fullscreen
Browse files Browse the repository at this point in the history
version 2.1.0
  • Loading branch information
krjw-eyev committed Oct 7, 2024
1 parent 9e3a427 commit 8278e06
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 49 deletions.
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if (flutterVersionName == null) {
}

android {
namespace "com.example.skyle_ik"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

Expand Down
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.ndk.suppressMinSdkVersionError=21
13 changes: 10 additions & 3 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:gaze_interactive/api.dart';
import 'package:millimeters/millimeters.dart';
import 'package:skyle_api/api.dart' as skyle;
import 'package:skyle_ik/config/positioning_type_notifier.dart';
import 'package:universal_platform/universal_platform.dart';
Expand All @@ -25,7 +26,7 @@ import 'ui/main/theme.dart';
import 'util/windows_monitor.dart';

class SkyleApp extends ConsumerStatefulWidget {
const SkyleApp({Key? key}) : super(key: key);
const SkyleApp({super.key});

@override
ConsumerState<SkyleApp> createState() => _SkyleAppState();
Expand Down Expand Up @@ -148,7 +149,9 @@ class _SkyleAppState extends ConsumerState<SkyleApp> with WidgetsBindingObserver
skyle.IPadModel model;
final deviceInfo = DeviceInfoPlugin();
final iosInfo = await deviceInfo.iosInfo;
final deviceModel = iosInfo.utsname.machine!;
final deviceModel = iosInfo.utsname.machine;
final size = Millimeters.of(context).physical;

model = skyle.IPadModel.values.firstWhere((element) => element.name == deviceModel.replaceAll(',', '_'), orElse: () {
print('iPad $deviceModel is not compatible with Skyle');
return skyle.IPadModel.iPad13_11;
Expand All @@ -159,6 +162,10 @@ class _SkyleAppState extends ConsumerState<SkyleApp> with WidgetsBindingObserver
width: width,
height: height,
),
dimensions: skyle.Size(
width: size.width,
height: size.height,
),
),
);
final zoomed = MediaQueryExtension.isZoomed(context);
Expand All @@ -178,7 +185,7 @@ class _SkyleAppState extends ConsumerState<SkyleApp> with WidgetsBindingObserver
changed = true;
print('Reset because of iPadModel = $model');
}
final isOld = iosInfo.systemVersion!.compareTo('13.4') < 0;
final isOld = iosInfo.systemVersion.compareTo('13.4') < 0;
if (iPadOS.isOld != isOld) {
iPadOS = iPadOS.copyWith(isOld: isOld);
changed = true;
Expand Down
4 changes: 2 additions & 2 deletions lib/config/routes/main_route_information_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import 'route_state.dart';
class MainRouteInformationParser extends RouteInformationParser<RouteState> {
@override
Future<RouteState> parseRouteInformation(RouteInformation routeInformation) async {
final uri = Uri.parse(routeInformation.location!);
final uri = Uri.parse(routeInformation.uri.path);
String? id;
return RouteState(route: uri.path, id: id);
}

@override
RouteInformation restoreRouteInformation(RouteState configuration) {
return RouteInformation(location: configuration.route);
return RouteInformation(uri: Uri.parse(configuration.route));
}
}
28 changes: 19 additions & 9 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
//

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:gaze_interactive/api.dart';
import 'package:millimeters/millimeters.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:skyle_api/api.dart' as skyle;
import 'package:universal_platform/universal_platform.dart';
import 'package:window_size/window_size.dart';
import 'package:window_manager/window_manager.dart';

import 'app.dart';
import 'config/app_state.dart';
Expand All @@ -24,11 +23,22 @@ Future<void> main() async {
AppState().sharedPreferences = await SharedPreferences.getInstance();
skyle.ET.logger = Logger();

if (UniversalPlatform.isMacOS) {
final Screen screen = (await getCurrentScreen())!;
setWindowFrame(screen.frame);
setWindowMinSize(const Size(1024, 768));
}
await windowManager.ensureInitialized();
const windowOptions = WindowOptions(center: true, minimumSize: Size(1440, 900), titleBarStyle: TitleBarStyle.hidden);
await windowManager.waitUntilReadyToShow(windowOptions, () async {
await windowManager.show();
await windowManager.focus();
await windowManager.setSize(const Size(1440, 900));
});

runApp(GazeContext(sharedPreferences: AppState().sharedPreferences, child: const SkyleApp()));
print(windowManager.getDevicePixelRatio());

runApp(
Millimeters.fromView(
child: GazeContext(
sharedPreferences: AppState().sharedPreferences,
child: const SkyleApp(),
),
),
);
}
17 changes: 12 additions & 5 deletions lib/ui/calibration/calibration_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:gaze_interactive/api.dart';
import 'package:millimeters/millimeters.dart';
import 'package:skyle_api/api.dart' as skyle;
import 'package:window_manager/window_manager.dart';

import '../../config/routes/main_routes.dart';
import '../../config/routes/routes.dart';
Expand All @@ -20,7 +22,7 @@ import '../calibration/pointer_view.dart';
import '../calibration/reference_points_view.dart';

class CalibrationView extends ConsumerStatefulWidget {
const CalibrationView({Key? key}) : super(key: key);
const CalibrationView({super.key});

@override
ConsumerState<CalibrationView> createState() => _CalibrationViewState();
Expand Down Expand Up @@ -59,24 +61,27 @@ class _CalibrationViewState extends ConsumerState<CalibrationView> with SingleTi

SchedulerBinding.instance.addPostFrameCallback((_) async {
await Future.delayed(const Duration(milliseconds: 1000));

if (mounted) {
calibrationProvider = StreamProvider.autoDispose((ref) {
ref.onDispose(() {
AppState().et.calibration.abort();
});
final MediaQueryData mediaQuery = MediaQuery.of(context);
final calibrationPoints = ref.read(AppState().calibrationPointsProvider);

print("Starting calibration");
final size = Millimeters.of(context).physical;
print(size);
return AppState().et.calibration.calibrate(
calibrationPoints,
screenSizes: skyle.ScreenSizes(
resolution: skyle.Size(
width: mediaQuery.size.width,
height: mediaQuery.size.height,
),
dimensions: const skyle.Size(
width: 1920,
height: 1080,
dimensions: skyle.Size(
width: size.width,
height: size.height,
),
),
stepped: true,
Expand All @@ -92,6 +97,7 @@ class _CalibrationViewState extends ConsumerState<CalibrationView> with SingleTi

Future<void> _listener(skyle.Connection connection) async {
if (connection == skyle.Connection.disconnected) {
Future.delayed(const Duration(milliseconds: 300), () async => windowManager.setFullScreen(false));
Routes.backAll();
}
}
Expand Down Expand Up @@ -180,6 +186,7 @@ class _CalibrationViewState extends ConsumerState<CalibrationView> with SingleTi
await AppState().et.settings.disableMouse();
}
});
Future.delayed(const Duration(milliseconds: 300), () async => windowManager.setFullScreen(false));
Routes.backAll();
},
route: MainRoutes.capture.path,
Expand Down
5 changes: 4 additions & 1 deletion lib/ui/main/main_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:gaze_interactive/api.dart';
import 'package:minimize_app/minimize_app.dart';
import 'package:skyle_api/api.dart';
import 'package:universal_platform/universal_platform.dart';
import 'package:window_manager/window_manager.dart';

import '../../config/routes/main_routes.dart';
import '../../config/routes/routes.dart';
Expand Down Expand Up @@ -271,7 +272,9 @@ class _StartButton extends StatelessWidget {
),
route: MainRoutes.home.path,
),
onTap: () {
onTap: () async {
windowManager.setFullScreen(true);
await Future.delayed(const Duration(milliseconds: 500));
Routes.route(MainRoutes.capture.path);
},
),
Expand Down
12 changes: 8 additions & 4 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
#include "generated_plugin_registrant.h"

#include <audioplayers_linux/audioplayers_linux_plugin.h>
#include <window_size/window_size_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h>
#include <window_manager/window_manager_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin");
audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar);
g_autoptr(FlPluginRegistrar) window_size_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowSizePlugin");
window_size_plugin_register_with_registrar(window_size_registrar);
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
screen_retriever_plugin_register_with_registrar(screen_retriever_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);
}
3 changes: 2 additions & 1 deletion linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_linux
window_size
screen_retriever
window_manager
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down
8 changes: 6 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ import Foundation

import audioplayers_darwin
import device_info_plus
import millimeters
import path_provider_foundation
import screen_retriever
import shared_preferences_foundation
import speech_to_text
import window_size
import window_manager

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
MillimetersPlugin.register(with: registry.registrar(forPlugin: "MillimetersPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SpeechToTextPlugin.register(with: registry.registrar(forPlugin: "SpeechToTextPlugin"))
WindowSizePlugin.register(with: registry.registrar(forPlugin: "WindowSizePlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
}
22 changes: 17 additions & 5 deletions macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ PODS:
- device_info_plus (0.0.1):
- FlutterMacOS
- FlutterMacOS (1.0.0)
- millimeters (0.0.1):
- FlutterMacOS
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- screen_retriever (0.0.1):
- FlutterMacOS
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
Expand All @@ -15,17 +19,19 @@ PODS:
- FlutterMacOS
- Try
- Try (2.1.1)
- window_size (0.0.2):
- window_manager (0.2.0):
- FlutterMacOS

DEPENDENCIES:
- audioplayers_darwin (from `Flutter/ephemeral/.symlinks/plugins/audioplayers_darwin/macos`)
- device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- millimeters (from `Flutter/ephemeral/.symlinks/plugins/millimeters/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
- speech_to_text (from `Flutter/ephemeral/.symlinks/plugins/speech_to_text/darwin`)
- window_size (from `Flutter/ephemeral/.symlinks/plugins/window_size/macos`)
- window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)

SPEC REPOS:
trunk:
Expand All @@ -38,24 +44,30 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos
FlutterMacOS:
:path: Flutter/ephemeral
millimeters:
:path: Flutter/ephemeral/.symlinks/plugins/millimeters/macos
path_provider_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
screen_retriever:
:path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos
shared_preferences_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
speech_to_text:
:path: Flutter/ephemeral/.symlinks/plugins/speech_to_text/darwin
window_size:
:path: Flutter/ephemeral/.symlinks/plugins/window_size/macos
window_manager:
:path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos

SPEC CHECKSUMS:
audioplayers_darwin: dcad41de4fbd0099cb3749f7ab3b0cb8f70b810c
device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
millimeters: 2ac76daaf7ecbfbee7f85f0c43845282af3fcff5
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
speech_to_text: 627d3fd2194770b51abb324ba45c2d39398f24a8
Try: 5ef669ae832617b3cee58cb2c6f99fb767a4ff96
window_size: 339dafa0b27a95a62a843042038fa6c3c48de195
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8

PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7

Expand Down
29 changes: 22 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.12.0"
millimeters:
dependency: "direct main"
description:
name: millimeters
sha256: bb79f045b7958b4faff406e911c058eec6c689e4784b4133d6a579d99664691f
url: "https://pub.dev"
source: hosted
version: "0.3.0"
minimize_app:
dependency: "direct main"
description:
Expand Down Expand Up @@ -682,6 +690,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.5"
screen_retriever:
dependency: transitive
description:
name: screen_retriever
sha256: "6ee02c8a1158e6dae7ca430da79436e3b1c9563c8cf02f524af997c201ac2b90"
url: "https://pub.dev"
source: hosted
version: "0.1.9"
shared_preferences:
dependency: "direct main"
description:
Expand Down Expand Up @@ -952,15 +968,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.5"
window_size:
window_manager:
dependency: "direct main"
description:
path: "plugins/window_size"
ref: HEAD
resolved-ref: eb3964990cf19629c89ff8cb4a37640c7b3d5601
url: "https://github.com/google/flutter-desktop-embedding.git"
source: git
version: "0.1.0"
name: window_manager
sha256: ab8b2a7f97543d3db2b506c9d875e637149d48ee0c6a5cb5f5fd6e0dac463792
url: "https://pub.dev"
source: hosted
version: "0.4.2"
xdg_directories:
dependency: transitive
description:
Expand Down
Loading

0 comments on commit 8278e06

Please sign in to comment.