Skip to content

Instantly share code, notes, and snippets.

@alicanbatur
Created July 29, 2022 10:23
Show Gist options
  • Save alicanbatur/4cbef6552d387016423f755ddada5c79 to your computer and use it in GitHub Desktop.
Save alicanbatur/4cbef6552d387016423f755ddada5c79 to your computer and use it in GitHub Desktop.
//
// ContentView.swift
// LiveActivity
//
// Created by Ali Can Batur on 28.07.2022.
//
import SwiftUI
import ActivityKit
struct ContentView: View {
let helper: LiveActivityHelper = LiveActivityHelper()
var body: some View {
VStack(spacing: 16) {
Button {
DispatchQueue
.main
.asyncAfter(deadline: .now() + 2,
execute: {
helper.start()
})
} label: {
Text("Start")
.font(.system(size: 18, weight: .medium))
}
Button {
DispatchQueue
.main
.asyncAfter(deadline: .now() + 2,
execute: {
helper.update()
})
} label: {
Text("Update with in progress")
.font(.system(size: 18, weight: .medium))
}
Button {
DispatchQueue
.main
.asyncAfter(deadline: .now() + 2,
execute: {
helper.end(with: .succeed)
})
} label: {
Text("End with succeed")
.font(.system(size: 18, weight: .medium))
}
Button {
DispatchQueue
.main
.asyncAfter(deadline: .now() + 2,
execute: {
helper.end(with: .failed)
})
} label: {
Text("End with failed")
.font(.system(size: 18, weight: .medium))
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment