Commit d0f45702 authored by Wei Han's avatar Wei Han

initial commit

parents
File added
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "ios_native_qms_test",
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.executableTarget(
name: "ios_native_qms_test"
),
]
)
# Uncomment the next line to define a global platform for your project
platform :ios, '15.0'
target 'ios_native_qms_test' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for ios_native_qms_test
pod 'QmsDashboard', :git => 'https://github.com/weihan-ng/WH_Plugin_Test', :tag => '0.1.6'
end
PODS:
- QmsDashboard (0.1.6)
DEPENDENCIES:
- QmsDashboard (from `https://github.com/weihan-ng/WH_Plugin_Test`, tag `0.1.6`)
EXTERNAL SOURCES:
QmsDashboard:
:git: https://github.com/weihan-ng/WH_Plugin_Test
:tag: 0.1.6
CHECKOUT OPTIONS:
QmsDashboard:
:git: https://github.com/weihan-ng/WH_Plugin_Test
:tag: 0.1.6
SPEC CHECKSUMS:
QmsDashboard: 70d7df2b8dba2d9ef6f0026757633b320ca29a76
PODFILE CHECKSUM: 7e6038f9d08ad3e448363dab2f2c3c5b8d896c18
COCOAPODS: 1.16.2
// The Swift Programming Language
// https://docs.swift.org/swift-book
@main
struct ios_native_qms_test {
static func main() {
print("Hello, world!")
}
}
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
{
"originHash" : "df5d522297366ea29eb86a7ff8970ddb166249f7342ceeee29b4c41e90d849c4",
"pins" : [
{
"identity" : "wh_plugin_test",
"kind" : "remoteSourceControl",
"location" : "https://github.com/weihan-ng/WH_Plugin_Test",
"state" : {
"revision" : "b2055b345669b030b70a5aef3729c6bd5cd7866d",
"version" : "0.1.6"
}
}
],
"version" : 3
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ios_native_qms_test.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:ios_native_qms_test.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "tinted"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
//
// ContentView.swift
// ios_native_qms_test
//
// Created by Wei Han Ng on 30/03/2026.
//
import SwiftUI
import QmsDashboard
struct ContentView: View {
@State private var didShowDashboard = false
// Replace these with your actual values
let clientID = "3"
let clientCode = "kitadev"
let userToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImF0aGlyYWh6YWlkaUBjb252ZXAuY29tIiwicGFzc3dvcmQiOiIkMnkkMTAkNU9xYklqMnZ6UHJwckJrcVd5c3I2LmJCc1hVYS9Hd014eUhnL3RhUUhPUkNQcGdmTG8yakciLCJzY29wZSI6IndpdGhpbi1zZXJ2ZXIiLCJmcmFtZXdvcmstYXBpIjp0cnVlLCJjb21wYW55X2NvZGUiOiJLSVRBREVWIiwic3ViIjoyMTcwLCJpc3MiOiJodHRwczovL2tpdGFkZXYuY29tbXVkZXNrLmNvbS9hcGkvZnJhbWV3b3JrL293bmVyL2F1dGgvcGFzc3dvcmRsZXNzX2xvZ2luIiwiaWF0IjoxNzcwNjI0NTEyLCJleHAiOjIwODYxOTQwMzIsIm5iZiI6MTc3MDYyNDUxMiwianRpIjoiSWRoTmpCTkRwMk9SY0pLUiJ9.B7iwbaaUietfSXASdVfSdE61LCi7ZH86BPHvIoi36Tw"
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, Potato!")
}
.padding()
// Present the QMS Dashboard automatically when the view appears
.onAppear {
showDashboardIfNeeded()
}
// Example: react to state changes safely in iOS 17+
.onChange(of: didShowDashboard) { oldValue, newValue in
print("Dashboard state changed from \(oldValue) to \(newValue)")
}
}
private func showDashboardIfNeeded() {
guard !didShowDashboard else { return }
// ✅ Get the root VC safely for iOS 15+
guard let rootVC = UIApplication.shared.connectedScenes
.compactMap({ $0 as? UIWindowScene })
.flatMap({ $0.windows })
.first(where: { $0.isKeyWindow })?
.rootViewController else {
print("Could not find root VC")
return
}
// ✅ Build and present QmsDashboard
QmsDashboardManager(
clientID: clientID,
clientCode: clientCode,
userToken: userToken
)
.setIsOrigin(true)
.setThemeColor("#0E7392")
.setAccentColor("#FFFFFF")
.setHeaderThemeColor("#FFFFFF")
.onClose {
print("Dashboard closed")
}
.onLogout {
print("User logged out")
}
.onAnalyticsScreen { screenName in
print("Analytics screen: \(screenName)")
}
.present(from: rootVC)
didShowDashboard = true
}
}
#Preview {
ContentView()
}
//
// ios_native_qms_testApp.swift
// ios_native_qms_test
//
// Created by Wei Han Ng on 30/03/2026.
//
import SwiftUI
@main
struct ios_native_qms_testApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
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