-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
피드화면 생성 1차 commit (사진등록제외)
- Loading branch information
Showing
5 changed files
with
282 additions
and
7 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
59 changes: 59 additions & 0 deletions
59
...ct02-teamB-OUR-consumer/project02-teamB-OUR-consumer/RecruitFeedView/RecruitFeedMap.swift
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,59 @@ | ||
// | ||
// RecruitFeedMap.swift | ||
// project02-teamB-OUR-consumer | ||
// | ||
// Created by kaikim on 2023/08/22. | ||
// | ||
|
||
import SwiftUI | ||
import CoreLocation | ||
import CoreLocationUI | ||
|
||
class LocationManager: NSObject, ObservableObject { | ||
|
||
private let manager = CLLocationManager() | ||
@Published var userLocation: CLLocation? | ||
static let shared = LocationManager() | ||
var addressString = "" | ||
|
||
override init() { | ||
super.init() | ||
manager.delegate = self | ||
manager.desiredAccuracy = kCLLocationAccuracyBest | ||
manager.startUpdatingLocation() | ||
} | ||
|
||
func requestLocation() { | ||
manager.requestWhenInUseAuthorization() | ||
} | ||
|
||
} | ||
|
||
extension LocationManager: CLLocationManagerDelegate { | ||
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { | ||
|
||
switch status { | ||
|
||
case .notDetermined: | ||
print("DEBUG: Not Determined") | ||
case .restricted: | ||
print("DEBUG: Restricted") | ||
case .denied: | ||
print("DEBUG: Denied") | ||
case .authorizedAlways: | ||
print("DEBUG: Auth always") | ||
case .authorizedWhenInUse: | ||
print("DEBUG: AUTH when in use") | ||
@unknown default: | ||
break | ||
} | ||
} | ||
|
||
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { | ||
guard let location = locations.last else { return} | ||
self.userLocation = location | ||
|
||
} | ||
|
||
|
||
} |
146 changes: 146 additions & 0 deletions
146
...t02-teamB-OUR-consumer/project02-teamB-OUR-consumer/RecruitFeedView/RecruitFeedView.swift
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,146 @@ | ||
// | ||
// RecruitFeedView.swift | ||
// project02-teamB-OUR-consumer | ||
// | ||
// Created by kaikim on 2023/08/22. | ||
// | ||
|
||
import SwiftUI | ||
import MapKit | ||
import CoreLocationUI | ||
import CoreLocation | ||
|
||
struct RecruitFeedView: View { | ||
|
||
@StateObject var locationManager = LocationManager.shared | ||
|
||
//임시적 변수(취소,등록) | ||
@State var toolbarToogle:Bool = false | ||
@State var privacySetting:PrivacySetting = PrivacySetting.Public | ||
@State var contentText:String = "" | ||
@State var placeholder:String = "Share Your Idea In OUR." | ||
@State var address: String = "" | ||
var body: some View { | ||
|
||
NavigationStack { | ||
ScrollView{ | ||
VStack(alignment: .leading){ | ||
HStack{ | ||
Picker("PrivacySetting", selection: $privacySetting) { | ||
Text("Public").tag(PrivacySetting.Public) | ||
Text("Private").tag(PrivacySetting.Private) | ||
} | ||
.pickerStyle(.menu) | ||
Spacer() | ||
} | ||
|
||
//현재위치설정 버튼 | ||
LocationButton(.currentLocation) { | ||
locationManager.requestLocation() | ||
|
||
} | ||
//위치설명 버튼 | ||
Button { | ||
convertLocationToAddress(location: locationManager.userLocation!) | ||
} label: { | ||
address.isEmpty ? Text("위치설명 버튼") : Text("\(address)") | ||
} | ||
|
||
} | ||
.padding() | ||
|
||
ZStack{ | ||
TextEditor(text: $contentText) | ||
.frame(minHeight:300, maxHeight:350) | ||
.buttonBorderShape(.roundedRectangle) | ||
.border(Color.secondary) | ||
|
||
if contentText.isEmpty { | ||
Text(placeholder) | ||
.foregroundColor(.secondary) | ||
} | ||
} | ||
|
||
Spacer() | ||
Section("Add Photo") { | ||
|
||
|
||
HStack{ | ||
Button(action: { | ||
|
||
}, label: { | ||
Image(systemName: "plus") | ||
.frame(width: 100,height: 100) | ||
.buttonBorderShape(.roundedRectangle) | ||
.border(Color.secondary) | ||
}) | ||
|
||
|
||
Button(action: { | ||
|
||
}, label: { | ||
Image(systemName: "plus") | ||
.frame(width: 100,height: 100) | ||
.buttonBorderShape(.roundedRectangle) | ||
.border(Color.secondary) | ||
}) | ||
|
||
|
||
Button(action: { | ||
|
||
}, label: { | ||
Image(systemName: "plus") | ||
.frame(width: 100,height: 100) | ||
.buttonBorderShape(.roundedRectangle) | ||
.border(Color.secondary) | ||
}) | ||
|
||
|
||
} | ||
.buttonBorderShape(.roundedRectangle) | ||
.border(Color.secondary) | ||
} | ||
Spacer() | ||
|
||
|
||
} | ||
.toolbar { | ||
ToolbarItem(placement:.navigationBarLeading) { | ||
Button("취소") { | ||
toolbarToogle.toggle() | ||
} | ||
} | ||
ToolbarItem(placement:.navigationBarTrailing) { | ||
Button("등록") { | ||
toolbarToogle.toggle() | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
func convertLocationToAddress(location: CLLocation) { | ||
//"en_US_POSIX" | ||
let geocoder = CLGeocoder() | ||
let locale = Locale(identifier: "ko-KR") | ||
geocoder.reverseGeocodeLocation(location, preferredLocale: locale) { (placemarks,error) in | ||
if error != nil { | ||
return | ||
} | ||
guard let placemark = placemarks?.first else {return} | ||
|
||
self.address = "\(placemark.country ?? "") \(placemark.locality ?? "") \(placemark.name ?? "")" | ||
} | ||
} | ||
} | ||
|
||
struct RecruitFeedView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
NavigationStack{ | ||
RecruitFeedView() | ||
} | ||
} | ||
} | ||
|
||
|
||
|
38 changes: 38 additions & 0 deletions
38
...eamB-OUR-consumer/project02-teamB-OUR-consumer/RecruitFeedView/RecruitFeedViewModel.swift
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,38 @@ | ||
// | ||
// RecruitFeedViewModel.swift | ||
// project02-teamB-OUR-consumer | ||
// | ||
// Created by kaikim on 2023/08/22. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
//아직 모델은 고민중 | ||
struct RecruitFeedViewModel { | ||
|
||
var privacySetting: Bool | ||
var title: String | ||
var content: String | ||
//var location: 뭐로할까 | ||
//var photo: Image 뭐로할까 | ||
var dateWriting: Date | ||
|
||
} | ||
|
||
//전체범위 공개 enum 처리 | ||
enum PrivacySetting { | ||
|
||
case Public | ||
case Private | ||
|
||
// 각 case에 맞게 가격을 화면에 보여주기 위해 | ||
var setting: String { | ||
switch self { | ||
case .Public: | ||
return "Public" | ||
case .Private: | ||
return "Private" | ||
} | ||
} | ||
} |