@marcos_feitoza/personal-finance-frontend-core-ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +23 -0
- package/.metadata +45 -0
- package/CHANGELOG.md +26 -0
- package/README.md +16 -0
- package/analysis_options.yaml +28 -0
- package/android/app/build.gradle.kts +44 -0
- package/android/app/src/debug/AndroidManifest.xml +7 -0
- package/android/app/src/main/AndroidManifest.xml +45 -0
- package/android/app/src/main/kotlin/com/example/personal_finance_frontend_core_ui/MainActivity.kt +5 -0
- package/android/app/src/main/res/drawable/launch_background.xml +12 -0
- package/android/app/src/main/res/drawable-v21/launch_background.xml +12 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/values/styles.xml +18 -0
- package/android/app/src/main/res/values-night/styles.xml +18 -0
- package/android/app/src/profile/AndroidManifest.xml +7 -0
- package/android/build.gradle.kts +21 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +3 -0
- package/android/settings.gradle.kts +25 -0
- package/ios/Flutter/AppFrameworkInfo.plist +26 -0
- package/ios/Flutter/Debug.xcconfig +1 -0
- package/ios/Flutter/Release.xcconfig +1 -0
- package/ios/Runner/AppDelegate.swift +13 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +122 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png +0 -0
- package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png +0 -0
- package/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +23 -0
- package/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png +0 -0
- package/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png +0 -0
- package/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png +0 -0
- package/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md +5 -0
- package/ios/Runner/Base.lproj/LaunchScreen.storyboard +37 -0
- package/ios/Runner/Base.lproj/Main.storyboard +26 -0
- package/ios/Runner/Info.plist +49 -0
- package/ios/Runner/Runner-Bridging-Header.h +1 -0
- package/ios/Runner.xcodeproj/project.pbxproj +619 -0
- package/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +101 -0
- package/ios/Runner.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/ios/RunnerTests/RunnerTests.swift +12 -0
- package/lib/main.dart +122 -0
- package/lib/personal_finance_frontend_core_ui.dart +1 -0
- package/lib/utils/currency_input_formatter.dart +49 -0
- package/lib/utils/currency_utils.dart +14 -0
- package/lib/utils/theme_notifier.dart +33 -0
- package/lib/widgets/app_widgets.dart +405 -0
- package/lib/widgets/crypto_trade_form.dart +357 -0
- package/lib/widgets/dividend_log_form.dart +151 -0
- package/lib/widgets/edit_transaction_dialog.dart +112 -0
- package/lib/widgets/expense_form.dart +238 -0
- package/lib/widgets/investment_form.dart +223 -0
- package/lib/widgets/rrsp_contribution_form.dart +157 -0
- package/lib/widgets/salary_form.dart +152 -0
- package/lib/widgets/trade_form.dart +374 -0
- package/lib/widgets/user_profile_avatar.dart +60 -0
- package/linux/CMakeLists.txt +128 -0
- package/linux/flutter/CMakeLists.txt +88 -0
- package/linux/flutter/generated_plugin_registrant.cc +11 -0
- package/linux/flutter/generated_plugin_registrant.h +15 -0
- package/linux/flutter/generated_plugins.cmake +23 -0
- package/linux/runner/CMakeLists.txt +26 -0
- package/linux/runner/main.cc +6 -0
- package/linux/runner/my_application.cc +130 -0
- package/linux/runner/my_application.h +18 -0
- package/macos/Flutter/Flutter-Debug.xcconfig +1 -0
- package/macos/Flutter/Flutter-Release.xcconfig +1 -0
- package/macos/Flutter/GeneratedPluginRegistrant.swift +10 -0
- package/macos/Runner/AppDelegate.swift +13 -0
- package/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
- package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png +0 -0
- package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png +0 -0
- package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png +0 -0
- package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png +0 -0
- package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png +0 -0
- package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png +0 -0
- package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png +0 -0
- package/macos/Runner/Base.lproj/MainMenu.xib +343 -0
- package/macos/Runner/Configs/AppInfo.xcconfig +14 -0
- package/macos/Runner/Configs/Debug.xcconfig +2 -0
- package/macos/Runner/Configs/Release.xcconfig +2 -0
- package/macos/Runner/Configs/Warnings.xcconfig +13 -0
- package/macos/Runner/DebugProfile.entitlements +12 -0
- package/macos/Runner/Info.plist +32 -0
- package/macos/Runner/MainFlutterWindow.swift +15 -0
- package/macos/Runner/Release.entitlements +8 -0
- package/macos/Runner.xcodeproj/project.pbxproj +705 -0
- package/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +99 -0
- package/macos/Runner.xcworkspace/contents.xcworkspacedata +7 -0
- package/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/macos/RunnerTests/RunnerTests.swift +12 -0
- package/package.json +29 -0
- package/pubspec.yaml +94 -0
- package/test/widget_test.dart +30 -0
- package/web/favicon.png +0 -0
- package/web/icons/Icon-192.png +0 -0
- package/web/icons/Icon-512.png +0 -0
- package/web/icons/Icon-maskable-192.png +0 -0
- package/web/icons/Icon-maskable-512.png +0 -0
- package/web/index.html +38 -0
- package/web/manifest.json +35 -0
- package/windows/CMakeLists.txt +108 -0
- package/windows/flutter/CMakeLists.txt +109 -0
- package/windows/flutter/generated_plugin_registrant.cc +11 -0
- package/windows/flutter/generated_plugin_registrant.h +15 -0
- package/windows/flutter/generated_plugins.cmake +23 -0
- package/windows/runner/CMakeLists.txt +40 -0
- package/windows/runner/Runner.rc +121 -0
- package/windows/runner/flutter_window.cpp +71 -0
- package/windows/runner/flutter_window.h +33 -0
- package/windows/runner/main.cpp +43 -0
- package/windows/runner/resource.h +16 -0
- package/windows/runner/resources/app_icon.ico +0 -0
- package/windows/runner/runner.exe.manifest +14 -0
- package/windows/runner/utils.cpp +65 -0
- package/windows/runner/utils.h +19 -0
- package/windows/runner/win32_window.cpp +288 -0
- package/windows/runner/win32_window.h +102 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.14)
|
|
2
|
+
project(runner LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
# Define the application target. To change its name, change BINARY_NAME in the
|
|
5
|
+
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
|
|
6
|
+
# work.
|
|
7
|
+
#
|
|
8
|
+
# Any new source files that you add to the application should be added here.
|
|
9
|
+
add_executable(${BINARY_NAME} WIN32
|
|
10
|
+
"flutter_window.cpp"
|
|
11
|
+
"main.cpp"
|
|
12
|
+
"utils.cpp"
|
|
13
|
+
"win32_window.cpp"
|
|
14
|
+
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
|
|
15
|
+
"Runner.rc"
|
|
16
|
+
"runner.exe.manifest"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
# Apply the standard set of build settings. This can be removed for applications
|
|
20
|
+
# that need different build settings.
|
|
21
|
+
apply_standard_settings(${BINARY_NAME})
|
|
22
|
+
|
|
23
|
+
# Add preprocessor definitions for the build version.
|
|
24
|
+
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
|
|
25
|
+
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
|
|
26
|
+
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
|
|
27
|
+
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
|
|
28
|
+
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
|
|
29
|
+
|
|
30
|
+
# Disable Windows macros that collide with C++ standard library functions.
|
|
31
|
+
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
|
|
32
|
+
|
|
33
|
+
# Add dependency libraries and include directories. Add any application-specific
|
|
34
|
+
# dependencies here.
|
|
35
|
+
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
|
36
|
+
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
|
|
37
|
+
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
|
38
|
+
|
|
39
|
+
# Run the Flutter tool portions of the build. This must not be removed.
|
|
40
|
+
add_dependencies(${BINARY_NAME} flutter_assemble)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// Microsoft Visual C++ generated resource script.
|
|
2
|
+
//
|
|
3
|
+
#pragma code_page(65001)
|
|
4
|
+
#include "resource.h"
|
|
5
|
+
|
|
6
|
+
#define APSTUDIO_READONLY_SYMBOLS
|
|
7
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
8
|
+
//
|
|
9
|
+
// Generated from the TEXTINCLUDE 2 resource.
|
|
10
|
+
//
|
|
11
|
+
#include "winres.h"
|
|
12
|
+
|
|
13
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
14
|
+
#undef APSTUDIO_READONLY_SYMBOLS
|
|
15
|
+
|
|
16
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
17
|
+
// English (United States) resources
|
|
18
|
+
|
|
19
|
+
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
|
20
|
+
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
|
21
|
+
|
|
22
|
+
#ifdef APSTUDIO_INVOKED
|
|
23
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
24
|
+
//
|
|
25
|
+
// TEXTINCLUDE
|
|
26
|
+
//
|
|
27
|
+
|
|
28
|
+
1 TEXTINCLUDE
|
|
29
|
+
BEGIN
|
|
30
|
+
"resource.h\0"
|
|
31
|
+
END
|
|
32
|
+
|
|
33
|
+
2 TEXTINCLUDE
|
|
34
|
+
BEGIN
|
|
35
|
+
"#include ""winres.h""\r\n"
|
|
36
|
+
"\0"
|
|
37
|
+
END
|
|
38
|
+
|
|
39
|
+
3 TEXTINCLUDE
|
|
40
|
+
BEGIN
|
|
41
|
+
"\r\n"
|
|
42
|
+
"\0"
|
|
43
|
+
END
|
|
44
|
+
|
|
45
|
+
#endif // APSTUDIO_INVOKED
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
49
|
+
//
|
|
50
|
+
// Icon
|
|
51
|
+
//
|
|
52
|
+
|
|
53
|
+
// Icon with lowest ID value placed first to ensure application icon
|
|
54
|
+
// remains consistent on all systems.
|
|
55
|
+
IDI_APP_ICON ICON "resources\\app_icon.ico"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
59
|
+
//
|
|
60
|
+
// Version
|
|
61
|
+
//
|
|
62
|
+
|
|
63
|
+
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
|
|
64
|
+
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
|
|
65
|
+
#else
|
|
66
|
+
#define VERSION_AS_NUMBER 1,0,0,0
|
|
67
|
+
#endif
|
|
68
|
+
|
|
69
|
+
#if defined(FLUTTER_VERSION)
|
|
70
|
+
#define VERSION_AS_STRING FLUTTER_VERSION
|
|
71
|
+
#else
|
|
72
|
+
#define VERSION_AS_STRING "1.0.0"
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
VS_VERSION_INFO VERSIONINFO
|
|
76
|
+
FILEVERSION VERSION_AS_NUMBER
|
|
77
|
+
PRODUCTVERSION VERSION_AS_NUMBER
|
|
78
|
+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
|
79
|
+
#ifdef _DEBUG
|
|
80
|
+
FILEFLAGS VS_FF_DEBUG
|
|
81
|
+
#else
|
|
82
|
+
FILEFLAGS 0x0L
|
|
83
|
+
#endif
|
|
84
|
+
FILEOS VOS__WINDOWS32
|
|
85
|
+
FILETYPE VFT_APP
|
|
86
|
+
FILESUBTYPE 0x0L
|
|
87
|
+
BEGIN
|
|
88
|
+
BLOCK "StringFileInfo"
|
|
89
|
+
BEGIN
|
|
90
|
+
BLOCK "040904e4"
|
|
91
|
+
BEGIN
|
|
92
|
+
VALUE "CompanyName", "com.example" "\0"
|
|
93
|
+
VALUE "FileDescription", "personal_finance_frontend_core_ui" "\0"
|
|
94
|
+
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
|
95
|
+
VALUE "InternalName", "personal_finance_frontend_core_ui" "\0"
|
|
96
|
+
VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0"
|
|
97
|
+
VALUE "OriginalFilename", "personal_finance_frontend_core_ui.exe" "\0"
|
|
98
|
+
VALUE "ProductName", "personal_finance_frontend_core_ui" "\0"
|
|
99
|
+
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
|
100
|
+
END
|
|
101
|
+
END
|
|
102
|
+
BLOCK "VarFileInfo"
|
|
103
|
+
BEGIN
|
|
104
|
+
VALUE "Translation", 0x409, 1252
|
|
105
|
+
END
|
|
106
|
+
END
|
|
107
|
+
|
|
108
|
+
#endif // English (United States) resources
|
|
109
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
#ifndef APSTUDIO_INVOKED
|
|
114
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
115
|
+
//
|
|
116
|
+
// Generated from the TEXTINCLUDE 3 resource.
|
|
117
|
+
//
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
121
|
+
#endif // not APSTUDIO_INVOKED
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#include "flutter_window.h"
|
|
2
|
+
|
|
3
|
+
#include <optional>
|
|
4
|
+
|
|
5
|
+
#include "flutter/generated_plugin_registrant.h"
|
|
6
|
+
|
|
7
|
+
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
|
|
8
|
+
: project_(project) {}
|
|
9
|
+
|
|
10
|
+
FlutterWindow::~FlutterWindow() {}
|
|
11
|
+
|
|
12
|
+
bool FlutterWindow::OnCreate() {
|
|
13
|
+
if (!Win32Window::OnCreate()) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
RECT frame = GetClientArea();
|
|
18
|
+
|
|
19
|
+
// The size here must match the window dimensions to avoid unnecessary surface
|
|
20
|
+
// creation / destruction in the startup path.
|
|
21
|
+
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
|
|
22
|
+
frame.right - frame.left, frame.bottom - frame.top, project_);
|
|
23
|
+
// Ensure that basic setup of the controller was successful.
|
|
24
|
+
if (!flutter_controller_->engine() || !flutter_controller_->view()) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
RegisterPlugins(flutter_controller_->engine());
|
|
28
|
+
SetChildContent(flutter_controller_->view()->GetNativeWindow());
|
|
29
|
+
|
|
30
|
+
flutter_controller_->engine()->SetNextFrameCallback([&]() {
|
|
31
|
+
this->Show();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Flutter can complete the first frame before the "show window" callback is
|
|
35
|
+
// registered. The following call ensures a frame is pending to ensure the
|
|
36
|
+
// window is shown. It is a no-op if the first frame hasn't completed yet.
|
|
37
|
+
flutter_controller_->ForceRedraw();
|
|
38
|
+
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void FlutterWindow::OnDestroy() {
|
|
43
|
+
if (flutter_controller_) {
|
|
44
|
+
flutter_controller_ = nullptr;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Win32Window::OnDestroy();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
LRESULT
|
|
51
|
+
FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
|
|
52
|
+
WPARAM const wparam,
|
|
53
|
+
LPARAM const lparam) noexcept {
|
|
54
|
+
// Give Flutter, including plugins, an opportunity to handle window messages.
|
|
55
|
+
if (flutter_controller_) {
|
|
56
|
+
std::optional<LRESULT> result =
|
|
57
|
+
flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
|
|
58
|
+
lparam);
|
|
59
|
+
if (result) {
|
|
60
|
+
return *result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
switch (message) {
|
|
65
|
+
case WM_FONTCHANGE:
|
|
66
|
+
flutter_controller_->engine()->ReloadSystemFonts();
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
|
|
71
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#ifndef RUNNER_FLUTTER_WINDOW_H_
|
|
2
|
+
#define RUNNER_FLUTTER_WINDOW_H_
|
|
3
|
+
|
|
4
|
+
#include <flutter/dart_project.h>
|
|
5
|
+
#include <flutter/flutter_view_controller.h>
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
|
|
9
|
+
#include "win32_window.h"
|
|
10
|
+
|
|
11
|
+
// A window that does nothing but host a Flutter view.
|
|
12
|
+
class FlutterWindow : public Win32Window {
|
|
13
|
+
public:
|
|
14
|
+
// Creates a new FlutterWindow hosting a Flutter view running |project|.
|
|
15
|
+
explicit FlutterWindow(const flutter::DartProject& project);
|
|
16
|
+
virtual ~FlutterWindow();
|
|
17
|
+
|
|
18
|
+
protected:
|
|
19
|
+
// Win32Window:
|
|
20
|
+
bool OnCreate() override;
|
|
21
|
+
void OnDestroy() override;
|
|
22
|
+
LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
|
|
23
|
+
LPARAM const lparam) noexcept override;
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
// The project to run.
|
|
27
|
+
flutter::DartProject project_;
|
|
28
|
+
|
|
29
|
+
// The Flutter instance hosted by this window.
|
|
30
|
+
std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
#endif // RUNNER_FLUTTER_WINDOW_H_
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#include <flutter/dart_project.h>
|
|
2
|
+
#include <flutter/flutter_view_controller.h>
|
|
3
|
+
#include <windows.h>
|
|
4
|
+
|
|
5
|
+
#include "flutter_window.h"
|
|
6
|
+
#include "utils.h"
|
|
7
|
+
|
|
8
|
+
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
|
9
|
+
_In_ wchar_t *command_line, _In_ int show_command) {
|
|
10
|
+
// Attach to console when present (e.g., 'flutter run') or create a
|
|
11
|
+
// new console when running with a debugger.
|
|
12
|
+
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
|
|
13
|
+
CreateAndAttachConsole();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Initialize COM, so that it is available for use in the library and/or
|
|
17
|
+
// plugins.
|
|
18
|
+
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
|
19
|
+
|
|
20
|
+
flutter::DartProject project(L"data");
|
|
21
|
+
|
|
22
|
+
std::vector<std::string> command_line_arguments =
|
|
23
|
+
GetCommandLineArguments();
|
|
24
|
+
|
|
25
|
+
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
|
|
26
|
+
|
|
27
|
+
FlutterWindow window(project);
|
|
28
|
+
Win32Window::Point origin(10, 10);
|
|
29
|
+
Win32Window::Size size(1280, 720);
|
|
30
|
+
if (!window.Create(L"personal_finance_frontend_core_ui", origin, size)) {
|
|
31
|
+
return EXIT_FAILURE;
|
|
32
|
+
}
|
|
33
|
+
window.SetQuitOnClose(true);
|
|
34
|
+
|
|
35
|
+
::MSG msg;
|
|
36
|
+
while (::GetMessage(&msg, nullptr, 0, 0)) {
|
|
37
|
+
::TranslateMessage(&msg);
|
|
38
|
+
::DispatchMessage(&msg);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
::CoUninitialize();
|
|
42
|
+
return EXIT_SUCCESS;
|
|
43
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//{{NO_DEPENDENCIES}}
|
|
2
|
+
// Microsoft Visual C++ generated include file.
|
|
3
|
+
// Used by Runner.rc
|
|
4
|
+
//
|
|
5
|
+
#define IDI_APP_ICON 101
|
|
6
|
+
|
|
7
|
+
// Next default values for new objects
|
|
8
|
+
//
|
|
9
|
+
#ifdef APSTUDIO_INVOKED
|
|
10
|
+
#ifndef APSTUDIO_READONLY_SYMBOLS
|
|
11
|
+
#define _APS_NEXT_RESOURCE_VALUE 102
|
|
12
|
+
#define _APS_NEXT_COMMAND_VALUE 40001
|
|
13
|
+
#define _APS_NEXT_CONTROL_VALUE 1001
|
|
14
|
+
#define _APS_NEXT_SYMED_VALUE 101
|
|
15
|
+
#endif
|
|
16
|
+
#endif
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2
|
+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
|
3
|
+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
|
4
|
+
<windowsSettings>
|
|
5
|
+
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
|
6
|
+
</windowsSettings>
|
|
7
|
+
</application>
|
|
8
|
+
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
|
9
|
+
<application>
|
|
10
|
+
<!-- Windows 10 and Windows 11 -->
|
|
11
|
+
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
|
12
|
+
</application>
|
|
13
|
+
</compatibility>
|
|
14
|
+
</assembly>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#include "utils.h"
|
|
2
|
+
|
|
3
|
+
#include <flutter_windows.h>
|
|
4
|
+
#include <io.h>
|
|
5
|
+
#include <stdio.h>
|
|
6
|
+
#include <windows.h>
|
|
7
|
+
|
|
8
|
+
#include <iostream>
|
|
9
|
+
|
|
10
|
+
void CreateAndAttachConsole() {
|
|
11
|
+
if (::AllocConsole()) {
|
|
12
|
+
FILE *unused;
|
|
13
|
+
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
|
|
14
|
+
_dup2(_fileno(stdout), 1);
|
|
15
|
+
}
|
|
16
|
+
if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
|
|
17
|
+
_dup2(_fileno(stdout), 2);
|
|
18
|
+
}
|
|
19
|
+
std::ios::sync_with_stdio();
|
|
20
|
+
FlutterDesktopResyncOutputStreams();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
std::vector<std::string> GetCommandLineArguments() {
|
|
25
|
+
// Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
|
|
26
|
+
int argc;
|
|
27
|
+
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
|
28
|
+
if (argv == nullptr) {
|
|
29
|
+
return std::vector<std::string>();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
std::vector<std::string> command_line_arguments;
|
|
33
|
+
|
|
34
|
+
// Skip the first argument as it's the binary name.
|
|
35
|
+
for (int i = 1; i < argc; i++) {
|
|
36
|
+
command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
::LocalFree(argv);
|
|
40
|
+
|
|
41
|
+
return command_line_arguments;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
std::string Utf8FromUtf16(const wchar_t* utf16_string) {
|
|
45
|
+
if (utf16_string == nullptr) {
|
|
46
|
+
return std::string();
|
|
47
|
+
}
|
|
48
|
+
unsigned int target_length = ::WideCharToMultiByte(
|
|
49
|
+
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
|
|
50
|
+
-1, nullptr, 0, nullptr, nullptr)
|
|
51
|
+
-1; // remove the trailing null character
|
|
52
|
+
int input_length = (int)wcslen(utf16_string);
|
|
53
|
+
std::string utf8_string;
|
|
54
|
+
if (target_length == 0 || target_length > utf8_string.max_size()) {
|
|
55
|
+
return utf8_string;
|
|
56
|
+
}
|
|
57
|
+
utf8_string.resize(target_length);
|
|
58
|
+
int converted_length = ::WideCharToMultiByte(
|
|
59
|
+
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
|
|
60
|
+
input_length, utf8_string.data(), target_length, nullptr, nullptr);
|
|
61
|
+
if (converted_length == 0) {
|
|
62
|
+
return std::string();
|
|
63
|
+
}
|
|
64
|
+
return utf8_string;
|
|
65
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#ifndef RUNNER_UTILS_H_
|
|
2
|
+
#define RUNNER_UTILS_H_
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <vector>
|
|
6
|
+
|
|
7
|
+
// Creates a console for the process, and redirects stdout and stderr to
|
|
8
|
+
// it for both the runner and the Flutter library.
|
|
9
|
+
void CreateAndAttachConsole();
|
|
10
|
+
|
|
11
|
+
// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
|
|
12
|
+
// encoded in UTF-8. Returns an empty std::string on failure.
|
|
13
|
+
std::string Utf8FromUtf16(const wchar_t* utf16_string);
|
|
14
|
+
|
|
15
|
+
// Gets the command line arguments passed in as a std::vector<std::string>,
|
|
16
|
+
// encoded in UTF-8. Returns an empty std::vector<std::string> on failure.
|
|
17
|
+
std::vector<std::string> GetCommandLineArguments();
|
|
18
|
+
|
|
19
|
+
#endif // RUNNER_UTILS_H_
|