Skip to content

Commit

Permalink
feat: RecruitFeedView Add
Browse files Browse the repository at this point in the history
피드화면 생성 1차 commit (사진등록제외)
  • Loading branch information
KaiKimiOS committed Aug 22, 2023
1 parent 2cf2093 commit 88f6644
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
9E99CCF02A944A5700699B6A /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E99CCEF2A944A5700699B6A /* ContentView.swift */; };
9E99CCF22A944A5A00699B6A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9E99CCF12A944A5A00699B6A /* Assets.xcassets */; };
9E99CCF52A944A5A00699B6A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9E99CCF42A944A5A00699B6A /* Preview Assets.xcassets */; };
B76000792A946E4E00F35291 /* RecruitFeedViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B76000782A946E4E00F35291 /* RecruitFeedViewModel.swift */; };
B760007B2A946E5900F35291 /* RecruitFeedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B760007A2A946E5900F35291 /* RecruitFeedView.swift */; };
B7610B832A94E3AA0074F78C /* RecruitFeedMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7610B822A94E3AA0074F78C /* RecruitFeedMap.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -19,6 +22,9 @@
9E99CCEF2A944A5700699B6A /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
9E99CCF12A944A5A00699B6A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
9E99CCF42A944A5A00699B6A /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
B76000782A946E4E00F35291 /* RecruitFeedViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecruitFeedViewModel.swift; sourceTree = "<group>"; };
B760007A2A946E5900F35291 /* RecruitFeedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecruitFeedView.swift; sourceTree = "<group>"; };
B7610B822A94E3AA0074F78C /* RecruitFeedMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecruitFeedMap.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -53,6 +59,7 @@
children = (
9E99CCED2A944A5700699B6A /* project02_teamB_OUR_consumerApp.swift */,
9E99CCEF2A944A5700699B6A /* ContentView.swift */,
B76000762A946E1F00F35291 /* RecruitFeedView */,
9E99CCF12A944A5A00699B6A /* Assets.xcassets */,
9E99CCF32A944A5A00699B6A /* Preview Content */,
);
Expand All @@ -67,6 +74,16 @@
path = "Preview Content";
sourceTree = "<group>";
};
B76000762A946E1F00F35291 /* RecruitFeedView */ = {
isa = PBXGroup;
children = (
B76000782A946E4E00F35291 /* RecruitFeedViewModel.swift */,
B760007A2A946E5900F35291 /* RecruitFeedView.swift */,
B7610B822A94E3AA0074F78C /* RecruitFeedMap.swift */,
);
path = RecruitFeedView;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -138,6 +155,9 @@
buildActionMask = 2147483647;
files = (
9E99CCF02A944A5700699B6A /* ContentView.swift in Sources */,
B760007B2A946E5900F35291 /* RecruitFeedView.swift in Sources */,
B7610B832A94E3AA0074F78C /* RecruitFeedMap.swift in Sources */,
B76000792A946E4E00F35291 /* RecruitFeedViewModel.swift in Sources */,
9E99CCEE2A944A5700699B6A /* project02_teamB_OUR_consumerApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -275,11 +295,13 @@
DEVELOPMENT_TEAM = ACJMUH34H4;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Please allow us to access your location";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -304,11 +326,13 @@
DEVELOPMENT_TEAM = ACJMUH34H4;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Please allow us to access your location";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@
//

import SwiftUI
import MapKit
import CoreLocationUI

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
NavigationStack{
VStack {
RecruitFeedView()
}
}
.padding()
}
}

#Preview {
ContentView()

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
NavigationStack{
ContentView()
}
}
}


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

}


}
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()
}
}
}



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"
}
}
}

0 comments on commit 88f6644

Please sign in to comment.