Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: delete button for secret location voew
- Loading branch information
Showing
8 changed files
with
159 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// DelPinAlert.swift | ||
// BaoAnGongFisher | ||
// | ||
// Created by nipapa on 2022/10/18. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct DelPinAlert: View { | ||
|
||
let screenSize = UIScreen.main.bounds | ||
@Binding var alertIsPresented: Bool | ||
@Binding var locationLoader: LocationLoader | ||
var boxTitle: String = "刪除釣點" | ||
|
||
var body: some View { | ||
VStack { | ||
Text(boxTitle) | ||
.font(.title2) | ||
.fontWeight(.semibold) | ||
ScrollView(.vertical) { | ||
LazyVStack { | ||
ForEach(Array(self.locationLoader.encodeCoordinate().enumerated()), id: \.element) { index, item in | ||
HStack { | ||
Text(item.name) | ||
.frame(alignment: .leading) | ||
.font(.headline) | ||
Spacer() | ||
Button { | ||
delSingleLocation(pin: item, index: index) | ||
} label: { | ||
Label("", systemImage: "xmark.bin.circle") | ||
.labelStyle(.iconOnly) | ||
.frame(width: 20, height:20) | ||
.foregroundColor(.white) | ||
.cornerRadius(5) | ||
.padding(10) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
.padding() | ||
.frame(width: screenSize.width * 0.6, height: screenSize.height * 0.4) | ||
.background(Color.indigo) | ||
.clipShape(RoundedRectangle(cornerRadius: 30, style: .continuous)) | ||
.shadow(color: Color.gray, radius: 15, x: -1, y: -1) | ||
.offset(y: alertIsPresented ? screenSize.height * 0.1 : screenSize.height) | ||
} | ||
|
||
func delSingleLocation(pin: FishPinAnnotation, index: Int) { | ||
//func delSingleLocation(at indexSet: IndexSet) { | ||
self.locationLoader.locationData.remove(at: index) | ||
self.locationLoader.saveAndReloadLocation() | ||
self.alertIsPresented.toggle() | ||
} | ||
} | ||
|
||
struct DelPinAlert_Previews: PreviewProvider { | ||
static var previews: some View { | ||
DelPinAlert(alertIsPresented: .constant(false), | ||
locationLoader: .constant(LocationLoader()) | ||
) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ struct MainListView: View { | |
Text("私藏釣點") | ||
} | ||
} | ||
.accentColor(.pink) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// AddStampAlert.swift | ||
// BaoAnGongFisher | ||
// | ||
// Created by nipapa on 2022/10/18. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct AddStampAlert: View { | ||
|
||
let screenSize = UIScreen.main.bounds | ||
@Binding var alertIsPresented: Bool | ||
@Binding var newStampName: String | ||
var boxTitle: String = "開郵票" | ||
|
||
var body: some View { | ||
VStack { | ||
Text(boxTitle) | ||
TextField("魚名", text: $newStampName) | ||
.textFieldStyle(RoundedBorderTextFieldStyle()) | ||
} | ||
.padding() | ||
.frame(width: screenSize.width * 0.6, height: screenSize.height * 0.2) | ||
.background(Color.cyan) | ||
.clipShape(RoundedRectangle(cornerRadius: 30, style: .continuous)) | ||
.shadow(color: Color.gray, radius: 15, x: -1, y: -1) | ||
.offset(y: alertIsPresented ? screenSize.height * 0.2 : screenSize.height) | ||
} | ||
} | ||
|
||
struct AddStampAlert_Previews: PreviewProvider { | ||
static var previews: some View { | ||
AddStampAlert( | ||
alertIsPresented: .constant(false), | ||
newStampName: .constant("xx魚") | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters