Commit 91919501 authored by Wei Han's avatar Wei Han

code update

parent 1511a7e0
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { StatusBar, useColorScheme, SafeAreaView, View } from 'react-native'; import {
StatusBar,
useColorScheme,
SafeAreaView,
View,
BackHandler,
} from 'react-native';
// import { showPluginUI, QmsDashboardView } from 'QmsPlugin'; // import { showPluginUI, QmsDashboardView } from 'QmsPlugin';
import { QmsDashboardView } from 'QmsPlugin'; import { QmsDashboardView } from 'QmsPlugin';
function App() { function App() {
const isDarkMode = useColorScheme() === 'dark'; const isDarkMode = useColorScheme() === 'dark';
const clientID = '3';
const clientCode = 'kita';
const userToken =
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImF0aGlyYWh6YWlkaUBjb252ZXAuY29tIiwicGFzc3dvcmQiOiIkMnkkMTAkNU9xYklqMnZ6UHJwckJrcVd5c3I2LmJCc1hVYS9Hd014eUhnL3RhUUhPUkNQcGdmTG8yakciLCJzdWIiOjIxNzAsImlzcyI6Imh0dHBzOi8va2l0YWRldi5jb21tdWRlc2suY29tL2FwaS9vd25lci9hdXRoL3Bhc3N3b3JkbGVzc19sb2dpbiIsImlhdCI6MTc2MDMxNTM1MiwiZXhwIjoyMDc1ODg0ODcyLCJuYmYiOjE3NjAzMTUzNTIsImp0aSI6IktoQmNyQnJEdDVNdDZlWmMifQ.JnxGbZ7hTeoOr6oibIzZMphgyKtTo2Aq9Efx6mrGfFA';
return ( return (
<SafeAreaView> <SafeAreaView>
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} /> <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<QmsDashboardView <QmsDashboardView
style={{ flex: 1 }} style={{ flex: 1 }}
ClientID={'client id test'} ClientID={clientID}
ClientCode={'client code test'} ClientCode={clientCode}
user_token={'user token test'} user_token={userToken}
onClose={() => {
// BackHandler.exitApp();
console.log('Dashboard closed'); // { status: 'closed' }
}}
/> />
</View> </View>
</SafeAreaView> </SafeAreaView>
......
...@@ -11,19 +11,19 @@ ...@@ -11,19 +11,19 @@
44006126336D83DB220E7214 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */; }; 44006126336D83DB220E7214 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */; };
761780ED2CA45674006654EE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 761780EC2CA45674006654EE /* AppDelegate.swift */; }; 761780ED2CA45674006654EE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 761780EC2CA45674006654EE /* AppDelegate.swift */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
A5EF1323781E74E1C85341EA /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 28928BBADA155E55F2B1BEB6 /* libPods-example.a */; }; E7409E55B58E814834562CC9 /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5114A1B6EF7A45CBC3B44888 /* libPods-example.a */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
059DA6A507896EEEC4EAC550 /* Pods-example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.release.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.release.xcconfig"; sourceTree = "<group>"; };
13B07F961A680F5B00A75B9A /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 13B07F961A680F5B00A75B9A /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; };
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = example/Images.xcassets; sourceTree = "<group>"; }; 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = example/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = example/Info.plist; sourceTree = "<group>"; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = example/Info.plist; sourceTree = "<group>"; };
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = example/PrivacyInfo.xcprivacy; sourceTree = "<group>"; }; 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = example/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
28928BBADA155E55F2B1BEB6 /* libPods-example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 1A4D3A8ADA7BADEA4472F767 /* Pods-example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.debug.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.debug.xcconfig"; sourceTree = "<group>"; };
2D377E449E2382FA80A2E644 /* Pods-example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.debug.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.debug.xcconfig"; sourceTree = "<group>"; }; 5114A1B6EF7A45CBC3B44888 /* libPods-example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
761780EC2CA45674006654EE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = example/AppDelegate.swift; sourceTree = "<group>"; }; 761780EC2CA45674006654EE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = example/AppDelegate.swift; sourceTree = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = example/LaunchScreen.storyboard; sourceTree = "<group>"; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = example/LaunchScreen.storyboard; sourceTree = "<group>"; };
A767065F2B7C703FC64B82F0 /* Pods-example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.release.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.release.xcconfig"; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */ /* End PBXFileReference section */
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
A5EF1323781E74E1C85341EA /* libPods-example.a in Frameworks */, E7409E55B58E814834562CC9 /* libPods-example.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
ED297162215061F000B7C4FE /* JavaScriptCore.framework */, ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
28928BBADA155E55F2B1BEB6 /* libPods-example.a */, 5114A1B6EF7A45CBC3B44888 /* libPods-example.a */,
); );
name = Frameworks; name = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -92,8 +92,8 @@ ...@@ -92,8 +92,8 @@
BBD78D7AC51CEA395F1C20DB /* Pods */ = { BBD78D7AC51CEA395F1C20DB /* Pods */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
2D377E449E2382FA80A2E644 /* Pods-example.debug.xcconfig */, 1A4D3A8ADA7BADEA4472F767 /* Pods-example.debug.xcconfig */,
059DA6A507896EEEC4EAC550 /* Pods-example.release.xcconfig */, A767065F2B7C703FC64B82F0 /* Pods-example.release.xcconfig */,
); );
path = Pods; path = Pods;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -105,13 +105,13 @@ ...@@ -105,13 +105,13 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "example" */; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "example" */;
buildPhases = ( buildPhases = (
931514101C7193957CD78569 /* [CP] Check Pods Manifest.lock */, 1DCE7F410965D5C781113361 /* [CP] Check Pods Manifest.lock */,
13B07F871A680F5B00A75B9A /* Sources */, 13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */, 13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
D389FC8348270872B1EA86E2 /* [CP] Embed Pods Frameworks */, C3A2FFFA13FFA1FBBEB4AA16 /* [CP] Embed Pods Frameworks */,
C5721EFBABE8191F26C12AF3 /* [CP] Copy Pods Resources */, 6DD180C10422588ED3399574 /* [CP] Copy Pods Resources */,
); );
buildRules = ( buildRules = (
); );
...@@ -183,7 +183,7 @@ ...@@ -183,7 +183,7 @@
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
}; };
931514101C7193957CD78569 /* [CP] Check Pods Manifest.lock */ = { 1DCE7F410965D5C781113361 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
C5721EFBABE8191F26C12AF3 /* [CP] Copy Pods Resources */ = { 6DD180C10422588ED3399574 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-resources.sh\"\n"; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-resources.sh\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
D389FC8348270872B1EA86E2 /* [CP] Embed Pods Frameworks */ = { C3A2FFFA13FFA1FBBEB4AA16 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
...@@ -255,7 +255,7 @@ ...@@ -255,7 +255,7 @@
/* Begin XCBuildConfiguration section */ /* Begin XCBuildConfiguration section */
13B07F941A680F5B00A75B9A /* Debug */ = { 13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 2D377E449E2382FA80A2E644 /* Pods-example.debug.xcconfig */; baseConfigurationReference = 1A4D3A8ADA7BADEA4472F767 /* Pods-example.debug.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
}; };
13B07F951A680F5B00A75B9A /* Release */ = { 13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 059DA6A507896EEEC4EAC550 /* Pods-example.release.xcconfig */; baseConfigurationReference = A767065F2B7C703FC64B82F0 /* Pods-example.release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
......
...@@ -8,32 +8,32 @@ ...@@ -8,32 +8,32 @@
<key>BinaryPath</key> <key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string> <string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>ios-arm64</string> <string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key> <key>LibraryPath</key>
<string>QmsPluginFramework.framework</string> <string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key> <key>SupportedArchitectures</key>
<array> <array>
<string>arm64</string> <string>arm64</string>
<string>x86_64</string>
</array> </array>
<key>SupportedPlatform</key> <key>SupportedPlatform</key>
<string>ios</string> <string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict> </dict>
<dict> <dict>
<key>BinaryPath</key> <key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string> <string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string> <string>ios-arm64</string>
<key>LibraryPath</key> <key>LibraryPath</key>
<string>QmsPluginFramework.framework</string> <string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key> <key>SupportedArchitectures</key>
<array> <array>
<string>arm64</string> <string>arm64</string>
<string>x86_64</string>
</array> </array>
<key>SupportedPlatform</key> <key>SupportedPlatform</key>
<string>ios</string> <string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict> </dict>
</array> </array>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<dict> <dict>
<key>Assets.car</key> <key>Assets.car</key>
<data> <data>
4/wVNoFd+WcEg7nmH9Hm5v1nm7s= tiDJHgS+Mbu43+C6GiuoJR1rE/s=
</data> </data>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
<data> <data>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
zhv68b8E95A9988/pvXA0JKzn5/KsdixWe45ATxfW3g= NzmSax3a+FRy3d2BvvftoEyaWVf17BzGCiO9/CkeCM8=
</data> </data>
</dict> </dict>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<dict> <dict>
<key>Assets.car</key> <key>Assets.car</key>
<data> <data>
4/wVNoFd+WcEg7nmH9Hm5v1nm7s= tiDJHgS+Mbu43+C6GiuoJR1rE/s=
</data> </data>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
<data> <data>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
zhv68b8E95A9988/pvXA0JKzn5/KsdixWe45ATxfW3g= NzmSax3a+FRy3d2BvvftoEyaWVf17BzGCiO9/CkeCM8=
</data> </data>
</dict> </dict>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
......
...@@ -11,10 +11,6 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -11,10 +11,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) NSString *user_token; @property (nonatomic, copy) NSString *user_token;
@property (nonatomic, weak) DrawerController *drawerController; @property (nonatomic, weak) DrawerController *drawerController;
- (instancetype)initWithClientID:(NSString *)clientID
clientCode:(NSString *)clientCode
userToken:(NSString *)userToken;
@property (nonatomic, copy) NSString *projectCode; @property (nonatomic, copy) NSString *projectCode;
@property (nonatomic, copy) NSString *projectName; @property (nonatomic, copy) NSString *projectName;
@property (nonatomic, copy) NSString *projectId; @property (nonatomic, copy) NSString *projectId;
......
...@@ -53,32 +53,17 @@ ...@@ -53,32 +53,17 @@
CGFloat _currentY; CGFloat _currentY;
} }
- (instancetype)initWithClientID:(NSString *)clientID
clientCode:(NSString *)clientCode
userToken:(NSString *)userToken {
self = [super initWithNibName:nil bundle:nil];
if (self) {
_ClientID = [clientID copy];
_ClientCode = [clientCode copy];
_user_token = [userToken copy];
}
return self;
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0]; self.view.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0];
_sectionViews = [NSMutableDictionary dictionary]; _sectionViews = [NSMutableDictionary dictionary];
[self setupHeader]; [self setupHeader];
[self setupScrollContent]; [self setupScrollContent];
[self setupFooter]; [self setupFooter];
[self showLoadingOverlay:@"Loading dashboard..."]; [self showLoadingOverlay:@"Loading dashboard..."];
[self checkAndRefreshAPIs];
NSLog(@"in viewDidLoad ClientID: %@, ClientCode: %@, user_token: %@", self.ClientID, self.ClientCode, self.user_token);
NSLog(@"dashboard.drawerController = %@", self.drawerController); NSLog(@"dashboard.drawerController = %@", self.drawerController);
// [[OfflineSyncManager shared] clearOfflineQueue]; // [[OfflineSyncManager shared] clearOfflineQueue];
...@@ -89,7 +74,6 @@ ...@@ -89,7 +74,6 @@
NSLog(@"Dashboard loaded, refreshing data"); NSLog(@"Dashboard loaded, refreshing data");
[self refreshDashboardContent]; [self refreshDashboardContent];
NSLog(@"in viewWillAppear ClientID: %@, ClientCode: %@, user_token: %@", self.ClientID, self.ClientCode, self.user_token);
self.navigationController.navigationBarHidden = YES; self.navigationController.navigationBarHidden = YES;
} }
...@@ -98,18 +82,6 @@ ...@@ -98,18 +82,6 @@
self.navigationController.navigationBarHidden = YES; self.navigationController.navigationBarHidden = YES;
} }
- (void)checkAndRefreshAPIs {
if (![self isReadyToLoadDashboard]) {
NSLog(@"⏳ Waiting for ClientID / ClientCode / Token...");
return;
}
NSLog(@"✅ All credentials ready. Loading dashboard.");
[self showLoadingOverlay:@"Loading dashboard..."];
[self refreshDashboardContent];
}
#pragma mark - Refresh Logic #pragma mark - Refresh Logic
- (void)refreshDashboardContent { - (void)refreshDashboardContent {
NSLog(@"🔁 Refreshing dashboard content..."); NSLog(@"🔁 Refreshing dashboard content...");
...@@ -1517,33 +1489,6 @@ ...@@ -1517,33 +1489,6 @@
} }
} }
- (BOOL)isReadyToLoadDashboard {
return (
self.ClientID.length > 0 &&
self.ClientCode.length > 0 &&
self.user_token.length > 0 &&
![self.ClientID isEqualToString:@"clientID_loading"] &&
![self.ClientCode isEqualToString:@"clientCode_loading"] &&
![self.user_token isEqualToString:@"userToken_loading"]
);
}
#pragma mark - prop setter
- (void)setClientID:(NSString *)ClientID {
_ClientID = [ClientID copy];
[self checkAndRefreshAPIs];
}
- (void)setClientCode:(NSString *)ClientCode {
_ClientCode = [ClientCode copy];
[self checkAndRefreshAPIs];
}
- (void)setUser_token:(NSString *)user_token {
_user_token = [user_token copy];
[self checkAndRefreshAPIs];
}
- (void)onBack { - (void)onBack {
[self.navigationController popViewControllerAnimated:YES]; [self.navigationController popViewControllerAnimated:YES];
} }
......
// DrawerController.m // DrawerController.m
#import "DrawerController.h" #import "DrawerController.h"
#import "DashboardViewController.h" #import "ProjectViewController.h"
NSString * const DrawerDidSelectItemNotification = @"DrawerDidSelectItemNotification"; NSString * const DrawerDidSelectItemNotification = @"DrawerDidSelectItemNotification";
@interface DrawerController () <UIGestureRecognizerDelegate> @interface DrawerController () <UIGestureRecognizerDelegate>
@property (nonatomic, strong) DashboardViewController *mainVC; @property (nonatomic, strong) ProjectViewController *mainVC;
@property (nonatomic, strong) UIViewController *drawerVC; @property (nonatomic, strong) UIViewController *drawerVC;
@property (nonatomic, strong) UIView *overlayView; @property (nonatomic, strong) UIView *overlayView;
@property (nonatomic, assign) BOOL drawerOpen; @property (nonatomic, assign) BOOL drawerOpen;
...@@ -27,7 +27,7 @@ NSString * const DrawerDidSelectItemNotification = @"DrawerDidSelectItemNotifica ...@@ -27,7 +27,7 @@ NSString * const DrawerDidSelectItemNotification = @"DrawerDidSelectItemNotifica
if (!self) return nil; if (!self) return nil;
// 1️⃣ Initialize DashboardViewController with props // 1️⃣ Initialize DashboardViewController with props
_mainVC = [[DashboardViewController alloc] initWithClientID:clientID _mainVC = [[ProjectViewController alloc] initWithClientID:clientID
clientCode:clientCode clientCode:clientCode
userToken:user_token]; userToken:user_token];
...@@ -55,7 +55,7 @@ NSString * const DrawerDidSelectItemNotification = @"DrawerDidSelectItemNotifica ...@@ -55,7 +55,7 @@ NSString * const DrawerDidSelectItemNotification = @"DrawerDidSelectItemNotifica
[self setupOverlay]; [self setupOverlay];
[self setupMainVC]; [self setupMainVC];
[self setupPanGesture]; [self setupPanGesture];
NSLog(@"🟩 DrawerController loaded. mainVC = %@", self.mainVC);
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(menuItemSelected:) selector:@selector(menuItemSelected:)
name:DrawerDidSelectItemNotification name:DrawerDidSelectItemNotification
...@@ -208,22 +208,43 @@ NSString * const DrawerDidSelectItemNotification = @"DrawerDidSelectItemNotifica ...@@ -208,22 +208,43 @@ NSString * const DrawerDidSelectItemNotification = @"DrawerDidSelectItemNotifica
#pragma mark - Prop Setters #pragma mark - Prop Setters
- (void)setClientID:(NSString *)ClientID { - (void)setClientID:(NSString *)ClientID {
_ClientID = [ClientID copy]; _ClientID = [ClientID copy];
if ([self.mainVC respondsToSelector:NSSelectorFromString(@"setClientID:")]) { NSLog(@"🟩 DrawerController setClientID: %@", _ClientID);
[self.mainVC setValue:_ClientID forKey:@"ClientID"];
UIViewController *targetVC = self.mainVC;
if ([targetVC isKindOfClass:[UINavigationController class]]) {
targetVC = ((UINavigationController *)targetVC).topViewController;
}
if ([targetVC respondsToSelector:@selector(setClientID:)]) {
[targetVC setValue:_ClientID forKey:@"ClientID"];
} }
} }
- (void)setClientCode:(NSString *)ClientCode { - (void)setClientCode:(NSString *)ClientCode {
_ClientCode = [ClientCode copy]; _ClientCode = [ClientCode copy];
if ([self.mainVC respondsToSelector:NSSelectorFromString(@"setClientCode:")]) { NSLog(@"🟩 DrawerController setClientCode: %@", _ClientCode);
[self.mainVC setValue:_ClientCode forKey:@"ClientCode"];
UIViewController *targetVC = self.mainVC;
if ([targetVC isKindOfClass:[UINavigationController class]]) {
targetVC = ((UINavigationController *)targetVC).topViewController;
}
if ([targetVC respondsToSelector:@selector(setClientCode:)]) {
[targetVC setValue:_ClientCode forKey:@"ClientCode"];
} }
} }
- (void)setUser_token:(NSString *)user_token { - (void)setUser_token:(NSString *)user_token {
_user_token = [user_token copy]; _user_token = [user_token copy];
if ([self.mainVC respondsToSelector:NSSelectorFromString(@"setUser_token:")]) { NSLog(@"🟩 DrawerController setUser_token: %@", _user_token);
[self.mainVC setValue:_user_token forKey:@"user_token"];
UIViewController *targetVC = self.mainVC;
if ([targetVC isKindOfClass:[UINavigationController class]]) {
targetVC = ((UINavigationController *)targetVC).topViewController;
}
if ([targetVC respondsToSelector:@selector(setUser_token:)]) {
[targetVC setValue:_user_token forKey:@"user_token"];
} }
} }
......
...@@ -10,4 +10,8 @@ ...@@ -10,4 +10,8 @@
@property (nonatomic, copy) NSString *ClientCode; @property (nonatomic, copy) NSString *ClientCode;
@property (nonatomic, copy) NSString *user_token; @property (nonatomic, copy) NSString *user_token;
- (instancetype)initWithClientID:(NSString *)clientID
clientCode:(NSString *)clientCode
userToken:(NSString *)userToken;
@end @end
...@@ -70,6 +70,12 @@ ...@@ -70,6 +70,12 @@
@property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) NSArray *projects; @property (nonatomic, strong) NSArray *projects;
@property (nonatomic, strong) UIView *loadingOverlay;
@property (nonatomic, strong) UIActivityIndicatorView *spinner;
@property (nonatomic, strong) UILabel *loadingLabel;
@property (nonatomic, assign) BOOL isLoadingDashboard;
@property (nonatomic, assign) BOOL didLoadDashboard;
@end @end
@implementation ProjectViewController @implementation ProjectViewController
...@@ -77,8 +83,7 @@ ...@@ -77,8 +83,7 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = UIColor.systemBackgroundColor; self.view.backgroundColor = UIColor.systemBackgroundColor;
[self requestProjectList]; [self checkAndRefreshAPIs];
[self requestCompanyCode];
[self setupHeader]; [self setupHeader];
[self setupCollectionView]; [self setupCollectionView];
} }
...@@ -93,6 +98,45 @@ ...@@ -93,6 +98,45 @@
self.navigationController.navigationBarHidden = YES; self.navigationController.navigationBarHidden = YES;
} }
- (instancetype)initWithClientID:(NSString *)clientID
clientCode:(NSString *)clientCode
userToken:(NSString *)userToken {
self = [super initWithNibName:nil bundle:nil];
if (self) {
_ClientID = [clientID copy];
_ClientCode = [clientCode copy];
_user_token = [userToken copy];
}
return self;
}
- (void)checkAndRefreshAPIs {
NSLog(@"🔍 Checking credentials...");
NSLog(@"ClientID: %@", self.ClientID);
NSLog(@"ClientCode: %@", self.ClientCode);
NSLog(@"user_token: %@", self.user_token);
[self showLoadingOverlay:@"Loading..."];
if (![self isReadyToLoadDashboard]) {
NSLog(@"⏳ Waiting for all credentials to be ready...");
return;
}
if (_isLoadingDashboard) return;
self.isLoadingDashboard = YES;
NSLog(@"✅ All credentials ready. ClientID: %@, ClientCode: %@, user_token: %@",
self.ClientID, self.ClientCode, self.user_token);
[APIConfig setAuthTokem:self.user_token];
[APIConfig setClientId:self.ClientID];
[self requestProjectList];
[self requestCompanyCode];
}
#pragma mark - Header Setup #pragma mark - Header Setup
- (void)setupHeader { - (void)setupHeader {
self.headerView = [[UIView alloc] init]; self.headerView = [[UIView alloc] init];
...@@ -107,12 +151,29 @@ ...@@ -107,12 +151,29 @@
[menuButton addTarget:self action:@selector(handleMenuButtonTapped) forControlEvents:UIControlEventTouchUpInside]; [menuButton addTarget:self action:@selector(handleMenuButtonTapped) forControlEvents:UIControlEventTouchUpInside];
[self.headerView addSubview:menuButton]; [self.headerView addSubview:menuButton];
self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.backButton setImage:[UIImage systemImageNamed:@"chevron.backward"]
forState:UIControlStateNormal];
self.backButton.tintColor = UIColor.whiteColor;
[self.backButton addTarget:self
action:@selector(onBack)
forControlEvents:UIControlEventTouchUpInside];
self.backButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.headerView addSubview:self.backButton];
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
[self.headerView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor], [self.headerView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor],
[self.headerView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor], [self.headerView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
[self.headerView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor], [self.headerView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
[self.headerView.heightAnchor constraintEqualToConstant:48], [self.headerView.heightAnchor constraintEqualToConstant:48],
[self.backButton.leadingAnchor constraintEqualToAnchor:self.headerView.leadingAnchor constant:8],
[self.backButton.centerYAnchor constraintEqualToAnchor:self.headerView.centerYAnchor],
[self.backButton.widthAnchor constraintEqualToConstant:32],
[self.backButton.heightAnchor constraintEqualToConstant:32],
[menuButton.trailingAnchor constraintEqualToAnchor:self.headerView.trailingAnchor constant:-16], [menuButton.trailingAnchor constraintEqualToAnchor:self.headerView.trailingAnchor constant:-16],
[menuButton.centerYAnchor constraintEqualToAnchor:self.headerView.centerYAnchor], [menuButton.centerYAnchor constraintEqualToAnchor:self.headerView.centerYAnchor],
[menuButton.widthAnchor constraintEqualToConstant:26], [menuButton.widthAnchor constraintEqualToConstant:26],
...@@ -217,6 +278,50 @@ ...@@ -217,6 +278,50 @@
return CGSizeMake(width, height); return CGSizeMake(width, height);
} }
#pragma mark - Loading Overlay
- (void)showLoadingOverlay:(NSString *)message {
if (!self.loadingOverlay) {
// Full screen overlay
self.loadingOverlay = [[UIView alloc] initWithFrame:self.view.bounds];
self.loadingOverlay.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
self.loadingOverlay.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// Spinner
self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
self.spinner.color = UIColor.whiteColor;
self.spinner.translatesAutoresizingMaskIntoConstraints = NO;
[self.loadingOverlay addSubview:self.spinner];
[self.spinner startAnimating];
// Label
self.loadingLabel = [[UILabel alloc] init];
self.loadingLabel.textColor = UIColor.whiteColor;
self.loadingLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
self.loadingLabel.translatesAutoresizingMaskIntoConstraints = NO;
self.loadingLabel.textAlignment = NSTextAlignmentCenter;
self.loadingLabel.text = message ?: @"Loading";
[self.loadingOverlay addSubview:self.loadingLabel];
// Constraints
[NSLayoutConstraint activateConstraints:@[
[self.spinner.centerXAnchor constraintEqualToAnchor:self.loadingOverlay.centerXAnchor],
[self.spinner.centerYAnchor constraintEqualToAnchor:self.loadingOverlay.centerYAnchor],
[self.loadingLabel.topAnchor constraintEqualToAnchor:self.spinner.bottomAnchor constant:16],
[self.loadingLabel.centerXAnchor constraintEqualToAnchor:self.loadingOverlay.centerXAnchor]
]];
} else {
self.loadingLabel.text = message ?: @"Loading";
}
[self.view addSubview:self.loadingOverlay];
}
- (void)hideLoadingOverlay {
[self.spinner stopAnimating];
[self.loadingOverlay removeFromSuperview];
}
#pragma mark - API #pragma mark - API
- (void)requestProjectList { - (void)requestProjectList {
[APIClient requestProjectList:^(BOOL success, NSDictionary *data, NSError *error) { [APIClient requestProjectList:^(BOOL success, NSDictionary *data, NSError *error) {
...@@ -227,6 +332,8 @@ ...@@ -227,6 +332,8 @@
NSString *filePath = [docsPath stringByAppendingPathComponent:@"projectList.txt"]; NSString *filePath = [docsPath stringByAppendingPathComponent:@"projectList.txt"];
[plainText writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil]; [plainText writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
NSLog(@"📁 projectList saved as plain text to: %@", filePath); NSLog(@"📁 projectList saved as plain text to: %@", filePath);
[self hideLoadingOverlay];
self.isLoadingDashboard = NO;
if (error || !data) { if (error || !data) {
NSLog(@"❌ Project list API failed: %@", error); NSLog(@"❌ Project list API failed: %@", error);
...@@ -265,7 +372,7 @@ ...@@ -265,7 +372,7 @@
} }
- (void)requestCompanyCode { - (void)requestCompanyCode {
[APIClient requestCompanyCode:@"kita" completion:^(BOOL success, NSDictionary *data, NSError *error) { [APIClient requestCompanyCode:self.ClientCode completion:^(BOOL success, NSDictionary *data, NSError *error) {
// debug // debug
NSString *plainText = [NSString stringWithFormat:@"%@", data]; NSString *plainText = [NSString stringWithFormat:@"%@", data];
...@@ -273,6 +380,8 @@ ...@@ -273,6 +380,8 @@
NSString *filePath = [docsPath stringByAppendingPathComponent:@"companyCode.txt"]; NSString *filePath = [docsPath stringByAppendingPathComponent:@"companyCode.txt"];
[plainText writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil]; [plainText writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
NSLog(@"📁 companyCode saved as plain text to: %@", filePath); NSLog(@"📁 companyCode saved as plain text to: %@", filePath);
[self hideLoadingOverlay];
self.isLoadingDashboard = NO;
if (error || !data) { if (error || !data) {
NSLog(@"❌ Company Code API failed: %@", error); NSLog(@"❌ Company Code API failed: %@", error);
...@@ -315,6 +424,12 @@ ...@@ -315,6 +424,12 @@
} }
#pragma mark - Helper #pragma mark - Helper
- (void)onBack {
[self.drawerController closeDrawer];
[[NSNotificationCenter defaultCenter] postNotificationName:@"QmsDashboardDidCloseNotification" object:nil userInfo:@{@"status": @"closed"}];
}
- (void)handleMenuButtonTapped { - (void)handleMenuButtonTapped {
NSLog(@"🍔 Menu button tapped"); NSLog(@"🍔 Menu button tapped");
if (self.drawerController) { if (self.drawerController) {
...@@ -324,4 +439,50 @@ ...@@ -324,4 +439,50 @@
} }
} }
- (BOOL)isReadyToLoadDashboard {
return (
self.ClientID.length > 0 &&
self.ClientCode.length > 0 &&
self.user_token.length > 0 &&
![self.ClientID isEqualToString:@"clientID_loading"] &&
![self.ClientCode isEqualToString:@"clientCode_loading"] &&
![self.user_token isEqualToString:@"userToken_loading"]
);
}
- (void)checkIfReady {
if ([self isReadyToLoadDashboard] && !self.didLoadDashboard && !self.isLoadingDashboard) {
NSLog(@"✅ Dashboard ready!");
self.didLoadDashboard = YES;
[self checkAndRefreshAPIs];
}
}
#pragma mark - prop setter
- (void)setClientID:(NSString *)ClientID {
NSLog(@"🟨 ProjectVC setClientID: %@", ClientID);
_ClientID = [ClientID copy];
NSLog(@"🟢 ProjectViewController received ClientID: %@", _ClientID);
[self checkIfReady];
}
- (void)setClientCode:(NSString *)ClientCode {
NSLog(@"🟨 ProjectVC setClientCode: %@", ClientCode);
_ClientCode = [ClientCode copy];
NSLog(@"🟢 ProjectViewController received ClientCode: %@", _ClientCode);
[self checkIfReady];
}
- (void)setUser_token:(NSString *)user_token {
NSLog(@"🟨 ProjectVC setUser_token: %@", user_token);
_user_token = [user_token copy];
NSLog(@"🟢 ProjectViewController received user_token: %@", _user_token);
[self checkIfReady];
}
@end @end
...@@ -17,15 +17,11 @@ ...@@ -17,15 +17,11 @@
drawer.profileName = @"placeholder"; drawer.profileName = @"placeholder";
drawer.profileEmail = @"placeholder"; drawer.profileEmail = @"placeholder";
// 2️⃣ Screens // 2️⃣ Main content UINavigationController (landing page)
ProjectViewController *project = [[ProjectViewController alloc] init]; // Landing page ProjectViewController *project = [[ProjectViewController alloc] init]; // Landing page
UnitViewController *unit = [[UnitViewController alloc] init]; // Secondary page
DashboardViewController *dashboard = [[DashboardViewController alloc] init];
// 3️⃣ UINavigationController with landing page
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:project]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:project];
// 4️⃣ Create drawer controller wrapping nav // 3️⃣ Create DrawerController with props only
NSString *clientID = @"clientID_loading"; NSString *clientID = @"clientID_loading";
NSString *clientCode = @"clientCode_loading"; NSString *clientCode = @"clientCode_loading";
NSString *userToken = @"userToken_loading"; NSString *userToken = @"userToken_loading";
...@@ -36,14 +32,13 @@ ...@@ -36,14 +32,13 @@
clientCode:clientCode clientCode:clientCode
userToken:userToken]; userToken:userToken];
// 5️⃣ Assign main content (nav) to drawerController // 4️⃣ Assign the UINavigationController as mainVC
[drawerController setValue:nav forKey:@"_mainVC"]; [drawerController setValue:nav forKey:@"_mainVC"];
// 6️⃣ Inject drawerController reference into all screens // 5️⃣ Assign drawerController references to screens
project.drawerController = drawerController; project.drawerController = drawerController;
unit.drawerController = drawerController;
dashboard.drawerController = drawerController;
// ✅ Now mainVC topViewController is project, which can receive props via DrawerController
return drawerController; return drawerController;
} }
......
...@@ -904,7 +904,7 @@ ...@@ -904,7 +904,7 @@
// Add form fields (same as DashboardInfo) // Add form fields (same as DashboardInfo)
appendFormField(@"data[os]", [APIConfig os] ); appendFormField(@"data[os]", [APIConfig os] );
appendFormField(@"data[project_id]", [APIConfig projectId] ); appendFormField(@"data[project_id]", [APIConfig projectId] );
appendFormField(@"data[client_id]", @"3"); appendFormField(@"data[client_id]", [APIConfig clientId] );
NSString *infoJson = @"{\"OS\":\"AND\",\"IMEI\":\"AND:2a2f13ff17b1cbb5\",\"OS_VERSION\":\"35\",\"MODEL\":\"2306EPN60G\",\"APP_VERSION\":\"1.22.26\"}"; NSString *infoJson = @"{\"OS\":\"AND\",\"IMEI\":\"AND:2a2f13ff17b1cbb5\",\"OS_VERSION\":\"35\",\"MODEL\":\"2306EPN60G\",\"APP_VERSION\":\"1.22.26\"}";
appendFormField(@"data[information]", infoJson); appendFormField(@"data[information]", infoJson);
......
...@@ -12,6 +12,10 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -12,6 +12,10 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)baseURL; + (NSString *)baseURL;
+ (void)setBaseURL:(NSString *)baseURL; + (void)setBaseURL:(NSString *)baseURL;
/// Client Id
+ (NSString *)clientId;
+ (void)setClientId:(NSString *)clientId;
//drawingplan //drawingplan
+ (NSString *)drawingPlanId; + (NSString *)drawingPlanId;
+ (void)setDrawingPlanId:(NSString *)drawingPlanId; + (void)setDrawingPlanId:(NSString *)drawingPlanId;
......
...@@ -7,6 +7,7 @@ static NSString *kBaseURL = @"https://kitadev.commudesk.com/api"; ...@@ -7,6 +7,7 @@ static NSString *kBaseURL = @"https://kitadev.commudesk.com/api";
static NSString *kDrawingPlanId = @""; static NSString *kDrawingPlanId = @"";
static NSString *kProjectId = @""; static NSString *kProjectId = @"";
static NSString *kAuthToken = @"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImF0aGlyYWh6YWlkaUBjb252ZXAuY29tIiwicGFzc3dvcmQiOiIkMnkkMTAkNU9xYklqMnZ6UHJwckJrcVd5c3I2LmJCc1hVYS9Hd014eUhnL3RhUUhPUkNQcGdmTG8yakciLCJzdWIiOjIxNzAsImlzcyI6Imh0dHBzOi8va2l0YWRldi5jb21tdWRlc2suY29tL2FwaS9vd25lci9hdXRoL3Bhc3N3b3JkbGVzc19sb2dpbiIsImlhdCI6MTc2MDMxNTM1MiwiZXhwIjoyMDc1ODg0ODcyLCJuYmYiOjE3NjAzMTUzNTIsImp0aSI6IktoQmNyQnJEdDVNdDZlWmMifQ.JnxGbZ7hTeoOr6oibIzZMphgyKtTo2Aq9Efx6mrGfFA"; static NSString *kAuthToken = @"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImF0aGlyYWh6YWlkaUBjb252ZXAuY29tIiwicGFzc3dvcmQiOiIkMnkkMTAkNU9xYklqMnZ6UHJwckJrcVd5c3I2LmJCc1hVYS9Hd014eUhnL3RhUUhPUkNQcGdmTG8yakciLCJzdWIiOjIxNzAsImlzcyI6Imh0dHBzOi8va2l0YWRldi5jb21tdWRlc2suY29tL2FwaS9vd25lci9hdXRoL3Bhc3N3b3JkbGVzc19sb2dpbiIsImlhdCI6MTc2MDMxNTM1MiwiZXhwIjoyMDc1ODg0ODcyLCJuYmYiOjE3NjAzMTUzNTIsImp0aSI6IktoQmNyQnJEdDVNdDZlWmMifQ.JnxGbZ7hTeoOr6oibIzZMphgyKtTo2Aq9Efx6mrGfFA";
static NSString *kClientId = @"3";
@implementation APIConfig @implementation APIConfig
#pragma mark - OS #pragma mark - OS
...@@ -26,6 +27,18 @@ static NSString *kAuthToken = @"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI ...@@ -26,6 +27,18 @@ static NSString *kAuthToken = @"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI
} }
} }
#pragma mark - Client Id
+ (NSString *)clientId {
return kClientId;
}
+ (void)setClientId:(NSString *)clientId {
if (clientId.length > 0) {
kClientId = [clientId copy];
NSLog(@"🌐 API baseURL set to: %@", kClientId);
}
}
#pragma mark - Project Id #pragma mark - Project Id
+ (NSString *)projectId { + (NSString *)projectId {
return kProjectId; return kProjectId;
......
...@@ -95,3 +95,48 @@ RCT_EXPORT_VIEW_PROPERTY(ClientCode, NSString) ...@@ -95,3 +95,48 @@ RCT_EXPORT_VIEW_PROPERTY(ClientCode, NSString)
RCT_EXPORT_VIEW_PROPERTY(user_token, NSString) RCT_EXPORT_VIEW_PROPERTY(user_token, NSString)
@end @end
#import <React/RCTEventEmitter.h>
#import <React/RCTBridgeModule.h>
@interface QmsDashboardEmitter : RCTEventEmitter <RCTBridgeModule>
@end
@implementation QmsDashboardEmitter
RCT_EXPORT_MODULE();
+ (id)allocWithZone:(NSZone *)zone {
static QmsDashboardEmitter *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [super allocWithZone:zone];
});
return sharedInstance;
}
- (instancetype)init {
if (self = [super init]) {
// Listen for the framework notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleDashboardClose:)
name:@"QmsDashboardDidCloseNotification"
object:nil];
}
return self;
}
- (NSArray<NSString *> *)supportedEvents {
return @[@"onClose"];
}
- (void)handleDashboardClose:(NSNotification *)note {
// Send event to JS
[self sendEventWithName:@"onClose" body:note.userInfo];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
...@@ -8,32 +8,32 @@ ...@@ -8,32 +8,32 @@
<key>BinaryPath</key> <key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string> <string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>ios-arm64</string> <string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key> <key>LibraryPath</key>
<string>QmsPluginFramework.framework</string> <string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key> <key>SupportedArchitectures</key>
<array> <array>
<string>arm64</string> <string>arm64</string>
<string>x86_64</string>
</array> </array>
<key>SupportedPlatform</key> <key>SupportedPlatform</key>
<string>ios</string> <string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict> </dict>
<dict> <dict>
<key>BinaryPath</key> <key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string> <string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string> <string>ios-arm64</string>
<key>LibraryPath</key> <key>LibraryPath</key>
<string>QmsPluginFramework.framework</string> <string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key> <key>SupportedArchitectures</key>
<array> <array>
<string>arm64</string> <string>arm64</string>
<string>x86_64</string>
</array> </array>
<key>SupportedPlatform</key> <key>SupportedPlatform</key>
<string>ios</string> <string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict> </dict>
</array> </array>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<dict> <dict>
<key>Assets.car</key> <key>Assets.car</key>
<data> <data>
4/wVNoFd+WcEg7nmH9Hm5v1nm7s= tiDJHgS+Mbu43+C6GiuoJR1rE/s=
</data> </data>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
<data> <data>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
zhv68b8E95A9988/pvXA0JKzn5/KsdixWe45ATxfW3g= NzmSax3a+FRy3d2BvvftoEyaWVf17BzGCiO9/CkeCM8=
</data> </data>
</dict> </dict>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<dict> <dict>
<key>Assets.car</key> <key>Assets.car</key>
<data> <data>
4/wVNoFd+WcEg7nmH9Hm5v1nm7s= tiDJHgS+Mbu43+C6GiuoJR1rE/s=
</data> </data>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
<data> <data>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
zhv68b8E95A9988/pvXA0JKzn5/KsdixWe45ATxfW3g= NzmSax3a+FRy3d2BvvftoEyaWVf17BzGCiO9/CkeCM8=
</data> </data>
</dict> </dict>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
......
// src/QmsDashboardView.tsx // src/QmsDashboardView.tsx
import React from 'react'; import React, { useEffect } from 'react';
import { requireNativeComponent } from 'react-native'; import { requireNativeComponent, NativeEventEmitter, NativeModules, ViewStyle } from 'react-native';
import type { ViewStyle } from 'react-native';
type Props = { type Props = {
style?: ViewStyle; style?: ViewStyle;
ClientID?: string; ClientID?: string;
ClientCode?: string; ClientCode?: string;
user_token?: string; user_token?: string;
// New callback for dashboard close
onClose?: (event: { status: string }) => void;
}; };
const NativeQmsDashboardView = requireNativeComponent<Props>('QmsDashboardView'); const NativeQmsDashboardView = requireNativeComponent<Props>('QmsDashboardView');
export const QmsDashboardView: React.FC<Props> = (props) => { export const QmsDashboardView: React.FC<Props> = ({ onClose, ...props }) => {
useEffect(() => {
let subscription: any;
if (onClose) {
const emitter = new NativeEventEmitter(NativeModules.QmsDashboardEmitter);
subscription = emitter.addListener('onClose', onClose);
}
return () => {
subscription?.remove();
};
}, [onClose]);
return <NativeQmsDashboardView {...props} />; return <NativeQmsDashboardView {...props} />;
}; };
// src/index.tsx
import QmsPlugin from './NativeQmsPlugin'; import QmsPlugin from './NativeQmsPlugin';
export { QmsDashboardView } from './QmsDashboardView'; export { QmsDashboardView } from './QmsDashboardView';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment