diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d7c5f4c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "inpus_touch", + "cwd": "inpus_touch", + "request": "launch", + "type": "dart" + }, + { + "name": "inpus_touch (profile mode)", + "cwd": "inpus_touch", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "inpus_touch (release mode)", + "cwd": "inpus_touch", + "request": "launch", + "type": "dart", + "flutterMode": "release" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/inpus_touch/.metadata b/inpus_touch/.metadata index a778330..5687179 100644 --- a/inpus_touch/.metadata +++ b/inpus_touch/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: "d211f42860350d914a5ad8102f9ec32764dc6d06" + revision: "78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9" channel: "stable" project_type: app @@ -13,26 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - - platform: android - create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - - platform: ios - create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 - platform: linux - create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - - platform: macos - create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - - platform: web - create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - - platform: windows - create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 # User provided section diff --git a/inpus_touch/lib/main.dart b/inpus_touch/lib/main.dart index 543347f..f83b0e9 100644 --- a/inpus_touch/lib/main.dart +++ b/inpus_touch/lib/main.dart @@ -1,5 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:dynamic_color/dynamic_color.dart'; +import 'package:flutter/scheduler.dart'; + void main() { runApp(const MainApp()); } @@ -9,12 +12,18 @@ class MainApp extends StatelessWidget { @override Widget build(BuildContext context) { - return const MaterialApp( - home: Scaffold( - body: Center( - child: Text('Hello World once again!'), - ), - ), - ); + return MaterialApp(home: DynamicColorBuilder( + builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) { + var brightness = + SchedulerBinding.instance.platformDispatcher.platformBrightness; + + bool isDark = brightness == Brightness.dark; + + Color accentColor = (isDark == true + ? (darkDynamic?.primary ?? Colors.grey.shade800) + : (lightDynamic?.primary ?? Colors.grey.shade200)); + + return Scaffold(backgroundColor: accentColor); + })); } } diff --git a/inpus_touch/linux/CMakeLists.txt b/inpus_touch/linux/CMakeLists.txt index 749c484..25e2109 100644 --- a/inpus_touch/linux/CMakeLists.txt +++ b/inpus_touch/linux/CMakeLists.txt @@ -123,6 +123,12 @@ foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) COMPONENT Runtime) endforeach(bundled_library) +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") diff --git a/inpus_touch/linux/flutter/generated_plugin_registrant.cc b/inpus_touch/linux/flutter/generated_plugin_registrant.cc index e71a16d..675b719 100644 --- a/inpus_touch/linux/flutter/generated_plugin_registrant.cc +++ b/inpus_touch/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) dynamic_color_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin"); + dynamic_color_plugin_register_with_registrar(dynamic_color_registrar); } diff --git a/inpus_touch/linux/flutter/generated_plugins.cmake b/inpus_touch/linux/flutter/generated_plugins.cmake index 2e1de87..3e303c1 100644 --- a/inpus_touch/linux/flutter/generated_plugins.cmake +++ b/inpus_touch/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + dynamic_color ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/inpus_touch/macos/Flutter/GeneratedPluginRegistrant.swift b/inpus_touch/macos/Flutter/GeneratedPluginRegistrant.swift index cccf817..507ed46 100644 --- a/inpus_touch/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/inpus_touch/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,8 @@ import FlutterMacOS import Foundation +import dynamic_color func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) } diff --git a/inpus_touch/pubspec.yaml b/inpus_touch/pubspec.yaml index bb56826..0747b05 100644 --- a/inpus_touch/pubspec.yaml +++ b/inpus_touch/pubspec.yaml @@ -7,13 +7,14 @@ environment: sdk: '>=3.1.5 <4.0.0' dependencies: + dynamic_color: ^1.6.9 flutter: sdk: flutter dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^3.0.1 flutter: uses-material-design: true diff --git a/inpus_touch/test/widget_test.dart b/inpus_touch/test/widget_test.dart new file mode 100644 index 0000000..77d6060 --- /dev/null +++ b/inpus_touch/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:inpus_touch/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/inpus_touch/windows/flutter/generated_plugin_registrant.cc b/inpus_touch/windows/flutter/generated_plugin_registrant.cc index 8b6d468..e4899a6 100644 --- a/inpus_touch/windows/flutter/generated_plugin_registrant.cc +++ b/inpus_touch/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + DynamicColorPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); } diff --git a/inpus_touch/windows/flutter/generated_plugins.cmake b/inpus_touch/windows/flutter/generated_plugins.cmake index b93c4c3..841e8c4 100644 --- a/inpus_touch/windows/flutter/generated_plugins.cmake +++ b/inpus_touch/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + dynamic_color ) list(APPEND FLUTTER_FFI_PLUGIN_LIST