Skip to content

Commit

Permalink
Demo app changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rleojoseph committed Aug 25, 2023
1 parent 159d6ef commit 8329696
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
38 changes: 35 additions & 3 deletions Example/Controllers/SwiftUI/Features/List/MiniAppListRowCell.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import SwiftUI
import MiniApp

struct MiniAppListRowCell: View {

@State var iconUrl: URL?
@State var displayName: String
@State var miniAppId: String
@State var versionTag: String
@State var versionId: String
@State var listType: ListType

var body: some View {
HStack {
Expand All @@ -17,6 +20,9 @@ struct MiniAppListRowCell: View {
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 40, height: 40, alignment: .center)
.contextMenu {
menuItems
}
}, placeholder: {
Rectangle()
.fill(Color(.systemGray3))
Expand All @@ -25,10 +31,13 @@ struct MiniAppListRowCell: View {
} else {
RemoteImageView(urlString: iconUrl?.absoluteString ?? "")
.frame(width: 60, height: 40, alignment: .center)
.contextMenu {
menuItems
}
}
Spacer()
}

VStack(spacing: 3) {
HStack {
Text(displayName)
Expand All @@ -53,14 +62,37 @@ struct MiniAppListRowCell: View {
.padding(10)
}
}

var menuItems: some View {
Group {
Button("Download", action: downloadMiniAppInBackground)
Button("Available already?", action: isMiniAppDownloadedAlready)
}
}

func downloadMiniAppInBackground() {
MiniApp.shared(with: ListConfiguration(listType: listType).sdkConfig).downloadMiniApp(appId: miniAppId, versionId: versionId) { result in
switch result {
case .success(_):
print("Download Completed")
case .failure(let error):
print("Error downloading Miniapp:", error)
}
}
}

func isMiniAppDownloadedAlready() {
}
}

struct MiniAppListRowCell_Previews: PreviewProvider {
static var previews: some View {
MiniAppListRowCell(
displayName: "MiniApp Sample",
miniAppId: "123",
versionTag: "0.7.2",
versionId: "abcdefgh-12345678-abcdefgh-12345678"
versionId: "abcdefgh-12345678-abcdefgh-12345678",
listType: .listI
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ extension MiniAppListView {
MiniAppListRowCell(
iconUrl: info.icon,
displayName: info.displayName ?? "",
miniAppId: info.id,
versionTag: info.version.versionTag,
versionId: info.version.versionId
versionId: info.version.versionId,
listType: viewModel.type
)
}
}
Expand Down

0 comments on commit 8329696

Please sign in to comment.