I want to depend the variety of shares to know which day individuals most frequently share. I obtain from the api min and max temp for the following 7 days, I want to share it by e-mail, message, and many others. tips on how to repair it in order that the applying works within the background.
-----ContentView
import SwiftUI
import Basis
struct ContentView: View {
//For the reason that response is an array of TaskEntry object
@State var outcomes = [WeatherModel]()
@State var sharetVeiw = ShareSheetView()
var physique: some View {
ScrollView{
VStack{
ForEach(outcomes, id: .id) { end in
VStack{
Spacer()
VStack{
Textual content("Potsdam").font(.title)
Textual content("((String(format: "%.1f", consequence.latitude)), (String(format:"%.1f", consequence.longitude)))").font(.footnote)
}
}.padding()
Spacer()
VStack{
Textual content("(String(format: "%.1f",consequence.currentWeather.temperature)) °C").font(.largeTitle)
}.padding(20)
Spacer()
VStack{
HStack{
Textual content("Minimal")
Spacer()
Textual content("Most")
}
ForEach(1..<8) { index in
HStack{
VStack{
Button(motion: {
// j
sharetVeiw.sharecounter(indexDay: index)
sharetVeiw.actionSheet(day: consequence.every day.time[index] , tempMin: consequence.every day.temperature2MMin[index], tempMax: consequence.every day.temperature2MMax[index])
})
{
Textual content("(String(format: "%.1f",consequence.every day.temperature2MMin[index])) °C ").padding(5)
Spacer()
Textual content("(String(format: "%.1f",consequence.every day.temperature2MMax[index])) °C ").padding(5)
}
}
}
}
}.padding(20)
}
}
}.onAppear() {
WeatherService().getDate { (outcomes) in
self.outcomes = outcomes
print("Examine level")
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
-----ShareSheetView
import SwiftUI
struct ShareSheetView: View {
@State non-public var depend: Int = 0
var physique: some View {
VStack{
Textual content("Good day")
}
}
func actionSheet(day: String, tempMin: Double, tempMax: Double) {
let textmessage = "Day: (day), nTemperature Min: (String(format: "%.1f", tempMin)) °C, nTemperature Max: (String(format: "%.1f", tempMax)) °C"
let activityVC = UIActivityViewController(activityItems: [textmessage], applicationActivities: nil)
UIApplication.shared.home windows.first?.rootViewController?.current(activityVC, animated: true, completion: nil)
}
func sharecounter(indexDay: Int) {
var myDictionary = [1: 0, 2: 0, 3: 0, 4: 0, 5:0, 6:0, 7:0]
myDictionary[indexDay]! += 1
print(myDictionary)
}
}
struct ShareSheetView_Previews: PreviewProvider {
static var previews: some View {
ShareSheetView()
}
}
import SwiftUI
-----Wetherapp
@principal
struct Wetherapp: App {
var physique: some Scene {
WindowGroup {
ContentView()
}
I want to promote every time what number of instances a day has been shared – what number of instances the person presses the button.
I wrote a operate the place it increments dictionary values by one, and the hot button is my weekday index.