forked from birdofpreyru/react-native-fs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.cpp
93 lines (79 loc) · 3.09 KB
/
App.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "pch.h"
#include "App.h"
#include "AutolinkedNativeModules.g.h"
#include "ReactPackageProvider.h"
using namespace winrt;
using namespace xaml;
using namespace xaml::Controls;
using namespace xaml::Navigation;
using namespace Windows::ApplicationModel;
namespace winrt::ReactNativeFsExample::implementation
{
/// <summary>
/// Initializes the singleton application object. This is the first line of
/// authored code executed, and as such is the logical equivalent of main() or
/// WinMain().
/// </summary>
App::App() noexcept
{
#if BUNDLE
JavaScriptBundleFile(L"index.windows");
InstanceSettings().UseWebDebugger(false);
InstanceSettings().UseFastRefresh(false);
#else
JavaScriptBundleFile(L"index");
InstanceSettings().UseWebDebugger(true);
InstanceSettings().UseFastRefresh(true);
#endif
#if _DEBUG
InstanceSettings().UseDeveloperSupport(true);
#else
InstanceSettings().UseDeveloperSupport(false);
#endif
RegisterAutolinkedNativeModulePackages(PackageProviders()); // Includes any autolinked modules
PackageProviders().Append(make<ReactPackageProvider>()); // Includes all modules in this project
InitializeComponent();
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
void App::OnLaunched(activation::LaunchActivatedEventArgs const& e)
{
super::OnLaunched(e);
Frame rootFrame = Window::Current().Content().as<Frame>();
rootFrame.Navigate(xaml_typename<MainPage>(), box_value(e.Arguments()));
}
/// <summary>
/// Invoked when the application is activated by some means other than normal launching.
/// </summary>
void App::OnActivated(Activation::IActivatedEventArgs const &e) {
auto preActivationContent = Window::Current().Content();
super::OnActivated(e);
if (!preActivationContent && Window::Current()) {
Frame rootFrame = Window::Current().Content().as<Frame>();
rootFrame.Navigate(xaml_typename<MainPage>(), nullptr);
}
}
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
void App::OnSuspending([[maybe_unused]] IInspectable const& sender, [[maybe_unused]] SuspendingEventArgs const& e)
{
// Save application state and stop any background activity
}
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void App::OnNavigationFailed(IInspectable const&, NavigationFailedEventArgs const& e)
{
throw hresult_error(E_FAIL, hstring(L"Failed to load Page ") + e.SourcePageType().Name);
}
} // namespace winrt::ReactNativeFsExample::implementation