NotificationsView.swift
HStackにonTapGestureを追加。
構造体配列のcheckedを切替。
[Product]-[Run]実行
左上のTabApplicationで戻って、Notificationsを選択。

HStackにonTapGestureを追加。
構造体配列のcheckedを切替。
var body: some View {
VStack{
List {
ForEach(0 ..< fruits.count) { index in
HStack {
Text(self.fruits[index].kind)
Spacer()
Text(self.fruits[index].checked ? "通知あり" : "通知なし")
Image(self.fruits[index].checked ? "toggleon" : "toggleoff")
}
}
}
}
}
→
var body: some View {
VStack{
List {
ForEach(0 ..< fruits.count) { index in
HStack {
Text(self.fruits[index].kind)
Spacer()
Text(self.fruits[index].checked ? "通知あり" : "通知なし")
Image(self.fruits[index].checked ? "toggleon" : "toggleoff")
}
.contentShape(Rectangle())
.onTapGesture {
self.fruits[index].checked.toggle()
}
}
}
}
}
左上のTabApplicationで戻って、Notificationsを選択。
