Skip to content

Commit e754b5a

Browse files
committed
added UgAsyncHttpClientExample
1 parent fe122b8 commit e754b5a

File tree

8 files changed

+320
-0
lines changed

8 files changed

+320
-0
lines changed
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"object": {
3+
"pins": [
4+
{
5+
"package": "async-http-client",
6+
"repositoryURL": "https://github.com/swift-server/async-http-client.git",
7+
"state": {
8+
"branch": null,
9+
"revision": "864c8d9e0ead5de7ba70b61c8982f89126710863",
10+
"version": "1.15.0"
11+
}
12+
},
13+
{
14+
"package": "swift-atomics",
15+
"repositoryURL": "https://github.com/apple/swift-atomics.git",
16+
"state": {
17+
"branch": null,
18+
"revision": "ff3d2212b6b093db7f177d0855adbc4ef9c5f036",
19+
"version": "1.0.3"
20+
}
21+
},
22+
{
23+
"package": "swift-collections",
24+
"repositoryURL": "https://github.com/apple/swift-collections.git",
25+
"state": {
26+
"branch": null,
27+
"revision": "937e904258d22af6e447a0b72c0bc67583ef64a2",
28+
"version": "1.0.4"
29+
}
30+
},
31+
{
32+
"package": "swift-log",
33+
"repositoryURL": "https://github.com/apple/swift-log.git",
34+
"state": {
35+
"branch": null,
36+
"revision": "32e8d724467f8fe623624570367e3d50c5638e46",
37+
"version": "1.5.2"
38+
}
39+
},
40+
{
41+
"package": "swift-nio",
42+
"repositoryURL": "https://github.com/apple/swift-nio.git",
43+
"state": {
44+
"branch": null,
45+
"revision": "9b2848d76f5caad08b97e71a04345aa5bdb23a06",
46+
"version": "2.49.0"
47+
}
48+
},
49+
{
50+
"package": "swift-nio-extras",
51+
"repositoryURL": "https://github.com/apple/swift-nio-extras.git",
52+
"state": {
53+
"branch": null,
54+
"revision": "cc1e5275079380c859417dbea8588531f1a90ec3",
55+
"version": "1.18.0"
56+
}
57+
},
58+
{
59+
"package": "swift-nio-http2",
60+
"repositoryURL": "https://github.com/apple/swift-nio-http2.git",
61+
"state": {
62+
"branch": null,
63+
"revision": "38feec96bcd929028939107684073554bf01abeb",
64+
"version": "1.25.2"
65+
}
66+
},
67+
{
68+
"package": "swift-nio-ssl",
69+
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
70+
"state": {
71+
"branch": null,
72+
"revision": "4fb7ead803e38949eb1d6fabb849206a72c580f3",
73+
"version": "2.23.0"
74+
}
75+
},
76+
{
77+
"package": "swift-nio-transport-services",
78+
"repositoryURL": "https://github.com/apple/swift-nio-transport-services.git",
79+
"state": {
80+
"branch": null,
81+
"revision": "c0d9a144cfaec8d3d596aadde3039286a266c15c",
82+
"version": "1.15.0"
83+
}
84+
}
85+
]
86+
},
87+
"version": 1
88+
}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// swift-tools-version:5.3
2+
3+
import PackageDescription
4+
import Foundation
5+
6+
let SCADE_SDK = ProcessInfo.processInfo.environment["SCADE_SDK"] ?? ""
7+
8+
let package = Package(
9+
name: "UgAsyncHttpClientExample",
10+
platforms: [
11+
.macOS(.v11)
12+
],
13+
products: [
14+
.library(
15+
name: "UgAsyncHttpClientExample",
16+
type: .static,
17+
targets: [
18+
"UgAsyncHttpClientExample"
19+
]
20+
)
21+
],
22+
dependencies: [
23+
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.9.0")
24+
],
25+
targets: [
26+
.target(
27+
name: "UgAsyncHttpClientExample",
28+
dependencies: [
29+
.product(name: "AsyncHTTPClient", package: "async-http-client")
30+
],
31+
exclude: ["main.page"],
32+
swiftSettings: [
33+
.unsafeFlags(["-F", SCADE_SDK], .when(platforms: [.macOS, .iOS])),
34+
.unsafeFlags(["-I", "\(SCADE_SDK)/include"], .when(platforms: [.android])),
35+
]
36+
)
37+
]
38+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import ScadeKit
2+
3+
extension MainPageAdapter {
4+
var label: SCDWidgetsLabel {
5+
return self.page?.getWidgetByName("label") as! SCDWidgetsLabel
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<xmi:XMI xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmi:version="2.0" xmi:id="0.6" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:graphics="http://scade.com/sdk/view/graphics" xmlns:layout="http://scade.com/sdk/layout" xmlns:navigation="http://scade.com/lattice/navigation" xmlns:widgets="http://scade.com/sdk/view/widgets">
3+
<widgets:Page name="main">
4+
<minArea width="430" height="932"/>
5+
<location/>
6+
<backgroundColor Red="248" Green="248" Blue="248"/>
7+
<children xsi:type="widgets:Label" text="label" name="label">
8+
<font fontFamily="ArialMT" size="17">
9+
<color Red="70" Green="70" Blue="70"/>
10+
</font>
11+
<layoutData xsi:type="layout:AutoLayoutData"/>
12+
<location x="182" y="168"/>
13+
<size width="36" height="19"/>
14+
<contentSize width="36" height="19"/>
15+
</children>
16+
<layout xsi:type="layout:AutoLayout"/>
17+
<maxArea width="430" height="932"/>
18+
<size width="430" height="932"/>
19+
</widgets:Page>
20+
<navigation:Navigation page="/0"/>
21+
</xmi:XMI>
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import ScadeKit
2+
import AsyncHTTPClient
3+
import Foundation
4+
5+
6+
class MainPageAdapter: SCDLatticePageAdapter {
7+
8+
@MainActor
9+
private func downloadDataAndUpdateUI() async {
10+
let httpClient = HTTPClient(eventLoopGroupProvider: .createNew)
11+
12+
do {
13+
let request = HTTPClientRequest(url: "http://google.com/")
14+
let response = try await httpClient.execute(request, timeout: .seconds(30))
15+
self.label.text = "GOT RESPONSE: \(response.status)"
16+
}
17+
catch {
18+
print("ERROR: \(error)")
19+
}
20+
21+
try! await httpClient.shutdown()
22+
}
23+
24+
// page adapter initialization
25+
override func load(_ path: String) {
26+
super.load(path)
27+
28+
Task {
29+
await downloadDataAndUpdateUI()
30+
}
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import ScadeKit
2+
3+
4+
5+
class UgAsyncHttpClientExample: SCDApplication {
6+
7+
let window = SCDLatticeWindow()
8+
let mainAdapter = MainPageAdapter()
9+
10+
override func onFinishLaunching() {
11+
mainAdapter.load("main.page")
12+
mainAdapter.show(view: window)
13+
}
14+
}

UgAsyncHttpClientExample/build.yaml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
spm:
2+
- url:
3+
from:
4+
path:
5+
branch:
6+
exact:
7+
revision:
8+
search-paths: []
9+
linked-libs: []
10+
11+
search-paths: []
12+
linked-libs: []
13+
14+
ios:
15+
name: UgAsyncHttpClientExample
16+
id: com.scade.asynchttpclientexample
17+
device-family: iphone # iphone, ipad or universal
18+
supported-interface-orientations: ['portrait'] # portrait, upside_down, landscape_left or landscape_right
19+
supported-interface-orientationsiPad: ['portrait']
20+
entitlements-file:
21+
app-delegate-file:
22+
export-method: ad-hoc # app-store, enterprise or development
23+
simulator:
24+
os: 12.1
25+
output: UgAsyncHttpClientExample/.build/ios-simulator
26+
extra-args:
27+
search-paths: []
28+
linked-libs: []
29+
device:
30+
os: 12.1
31+
output: UgAsyncHttpClientExample/.build/ios-device
32+
product-path: UgAsyncHttpClientExample/Product/ios-device
33+
extra-args:
34+
search-paths: []
35+
linked-libs: []
36+
mac:
37+
os: 10.11
38+
output: UgAsyncHttpClientExample/.build/scade-simulator
39+
extra-args:
40+
search-paths: []
41+
linked-libs: []
42+
sign:
43+
provision-profile:
44+
certificate:
45+
icons:
46+
iphone: # or ipad, sizes: 20X20, 29X29, 40X40, 60X60, 76X76, 83.5X83.5
47+
60X60_2X:
48+
76X76_2X:
49+
76X76_3X:
50+
83.5X83.5_2X:
51+
marketing:
52+
1024X1024_1X:
53+
plist:
54+
CFBundleShortVersionString: string# 1.0
55+
CFBundleVersion: string# 1
56+
NSLocationWhenInUseUsageDescription:
57+
NSCameraUsageDescription: Take pictures from camera
58+
NSPhotoLibraryUsageDescription: Choose a photo from your library
59+
60+
android:
61+
name: UgAsyncHttpClientExample
62+
id: com.scade.asynchttpclientexample
63+
version-name: 1.0.0
64+
version-code: 1
65+
build-type: Debug
66+
key-store-properties:
67+
google-api-key:
68+
manifest-file:
69+
permissions: []
70+
minSdkVersion: 28
71+
armeabi-v7a:
72+
output: UgAsyncHttpClientExample/.build/android-armeabi-v7a
73+
product-path: UgAsyncHttpClientExample/Product/android-armeabi-v7a
74+
extra-args:
75+
search-paths: []
76+
linked-libs: []
77+
arm64-v8a:
78+
output: UgAsyncHttpClientExample/.build/android-arm64-v8a
79+
product-path: UgAsyncHttpClientExample/Product/android-arm64-v8a
80+
extra-args:
81+
search-paths: []
82+
linked-libs: ["z"]
83+
x86:
84+
output: UgAsyncHttpClientExample/.build/android-x86
85+
product-path: UgAsyncHttpClientExample/Product/android-x86
86+
extra-args:
87+
search-paths: []
88+
linked-libs: []
89+
x86_64:
90+
output: UgAsyncHttpClientExample/.build/android-x86_64
91+
product-path: UgAsyncHttpClientExample/Product/android-x86_64
92+
extra-args:
93+
search-paths: []
94+
linked-libs: []
95+
intent-filters:
96+
- action:
97+
scheme:
98+
categories: []
99+
icons:
100+
mdpi:
101+
hdpi:
102+
xhdpi:
103+
xxhdpi:

0 commit comments

Comments
 (0)