Skip to content

Commit

Permalink
Merge pull request #72 from APPSCHOOL3-iOS/feature/#2-RecruitFeedView1
Browse files Browse the repository at this point in the history
Feature/#2 recruit feed view1
  • Loading branch information
KaiKimiOS authored Aug 25, 2023
2 parents 8408e50 + 9f1db7a commit 929eefe
Show file tree
Hide file tree
Showing 106 changed files with 1,355 additions and 142 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct FeedRecruitPHPickerViewControllerWrapper: UIViewControllerRepresentable {
}
}

//UIImage를 String으로 변환(파이어베이스)
extension UIImage {
func toString() -> String? {

Expand All @@ -61,3 +62,14 @@ extension UIImage {
return pngData?.base64EncodedString(options: .lineLength64Characters)
}
}

//String을 UIImage로 변환(파이어베이스)
//yourString.toImage() <- it will convert String to UIImage
extension String {
func toImage() -> UIImage? {
if let data = Data(base64Encoded: self, options: .ignoreUnknownCharacters){
return UIImage(data: data)
}
return nil
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// SharedViewModel.swift
// project02-teamB-OUR-consumer
//
// Created by 박서연 on 2023/08/24.
//

import SwiftUI

class SharedViewModel: ObservableObject {
@Published var selectedLocality: String = ""
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// StudyRecruitModel.swift
// project02-teamB-OUR-consumer
//
// Created by 박서연 on 2023/08/24.
//

import Foundation
import SwiftUI

struct StudyRecruitModel {
var id: String = UUID().uuidString
var creator: String
var studyTitle: String

var startAt: Date
var dueAt: Date

var description: String
var isOnline: Bool
var isOffline: Bool

var imageURL: [String]
var locationName: String // 이름
var reportCount: Int // 신고 횟수


private static let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yy년 M월 dd일 HH:mm"
return formatter
}()

var startDate: String {
return StudyRecruitModel.dateFormatter.string(from: startAt)
}

var dueDate: String {
return StudyRecruitModel.dateFormatter.string(from: dueAt)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// AddRecruitStore.swift
// project02-teamB-OUR-consumer
//
// Created by 박서연 on 2023/08/24.
//

import Foundation
import FirebaseFirestore
import FirebaseFirestoreSwift

class StudyRecruitStore: ObservableObject {

@Published var studyStores: [StudyRecruitModel] = []

let dbRef = Firestore.firestore().collection("StudyPosts")

func fetchFeeds() {

dbRef.getDocuments { (snapshot, error) in

self.studyStores.removeAll()

if let snapshot {
var tempStudys: [StudyRecruitModel] = []

for document in snapshot.documents {


let id: String = document.documentID
let docData: [String: Any] = document.data()
let creator: String = docData["creator"] as? String ?? ""
let studyTitle: String = docData["studyTitle"] as? String ?? ""

let description: String = docData["description"] as? String ?? ""
let isOnline: Bool = docData["isOnline"] as? Bool ?? false
let isOffline: Bool = docData["isOffline"] as? Bool ?? false

let imageURL: [String] = docData["imageURL"] as? [String] ?? []
let locationName: String = docData["locationName"] as? String ?? ""
let reportCount: Int = docData["reportCount"] as? Int ?? 0

let startAt: Date = docData["startAt"] as? Date ?? Date()
let dueAt: Date = docData["dueAt"] as? Date ?? Date()

let studys = StudyRecruitModel(id: id, creator: creator, studyTitle: studyTitle, startAt: startAt, dueAt: dueAt, description: description, isOnline: isOnline, isOffline: isOffline, imageURL: imageURL, locationName: locationName, reportCount: reportCount)
tempStudys.append(studys)
}

self.studyStores = tempStudys
}
}
}

func addFeed(_ study: StudyRecruitModel) {

dbRef.document(study.id)
.setData(["creator": study.creator,
"description": study.description,
"imageURL": study.imageURL,
"locationName": study.locationName,
"isOnline": study.isOnline,
"isOffline": study.isOffline,
"startAt": study.startAt,
"dueAt": study.dueAt,
"studyTitle": study.studyTitle,
"reportCount": study.reportCount])

fetchFeeds()
}


func removeFeed(_ study: StudyRecruitModel) {

dbRef.document(study.id).delete()

fetchFeeds()
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// LocationSheetView.swift
// project02-teamB-OUR-consumer
//
// Created by 여성은 on 2023/08/22.
//

import SwiftUI
import MapKit

struct Annotation: Identifiable {
var id: UUID = UUID()
let coordinate: CLLocationCoordinate2D
}

struct LocationSheetView: View {

@Binding var isShowingLocationSheet: Bool

var locationName: String = "광화문역 사거리"

var locationCoordinate: CLLocationCoordinate2D

//locationCoordinate 여기서 안받아오면 region에 바로 쓸 수 있으려나!?
@State private var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 37.5718,
longitude: 126.9769),
span: MKCoordinateSpan(latitudeDelta: 0.008, longitudeDelta: 0.008))

var body: some View {

NavigationStack {
HStack {
Image(systemName: "mappin.and.ellipse")
Text("\(locationName)")
.fontWeight(.heavy)
Spacer()
}
.navigationTitle("모임 장소 위치")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
isShowingLocationSheet = false
} label: {
Image(systemName: "xmark")
}
}
}

Map(coordinateRegion: $region,
annotationItems: [Annotation(coordinate: locationCoordinate)]) { annotation in
MapMarker(coordinate: annotation.coordinate)
}
.frame(height: 250)


}
.padding()
}
}

struct LocationSheetView_Previews: PreviewProvider {
static var previews: some View {
LocationSheetView(isShowingLocationSheet: .constant(false), locationCoordinate: CLLocationCoordinate2D(latitude: 37.5718, longitude: 126.9769))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//
// StudyCommentReportView.swift
// project02-teamB-OUR-consumer
//
// Created by 여성은 on 2023/08/23.
//

import SwiftUI

struct StudyCommentReportView: View {

@Environment(\.dismiss) private var dismiss
@Environment(\.presentationMode) var mode: Binding<PresentationMode>

var userId: String
var comment: StudyComment

//신고유형들 쭈루룩
let reports: [String] = ["스팸","사기 또는 거짓", "혐오 발언 또는 상징", "계정이 해킹당 했을 수 있음"]

@State var showAlert: Bool = false
@State var reportCategory: String = ""

@Binding var isEditing: Bool

var body: some View {
NavigationStack {
Divider()
VStack(alignment: .leading) {
Text("신고하는 댓글")
.fontWeight(.heavy)
StudyReplyDetailView(isEditing: $isEditing, userId: "성은", comment: comment)
.padding(10)
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(Color.gray, lineWidth: 0.5)
)

}

Divider()

Form {
Text("신고하는 이유")
.fontWeight(.heavy)
.padding([.bottom, .top], 5)
ForEach(reports, id: \.self) { report in

Button {
reportCategory = report
showAlert = true
} label: {
Text("\(report)")
.padding(.bottom, 5)

}
.foregroundColor(.black)
Divider()

}
}
.formStyle(.columns)




Spacer()
}
.navigationTitle("신고하기")
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading: Button(action : {
self.mode.wrappedValue.dismiss()
}){
Image(systemName: "chevron.backward")
})
.padding()
.alert(isPresented: $showAlert) {
Alert(title: Text("신고하시겠습니까?"),
message: Text("\"\(reportCategory)\" 사유로 신고합니다"),
primaryButton: .destructive(Text("신고하기")) {
print(reportCategory)
dismiss()//뷰 닫기
//신고관련된 함수넣기
},
secondaryButton: .cancel(Text("취소")))
}
}
}

struct StudyCommentReportView_Previews: PreviewProvider {
static var previews: some View {
NavigationStack{
StudyCommentReportView(userId: "성은", comment: StudyComment(userId: "성은", content: "최악의 스터디 소개글이네여 ;;"), isEditing: .constant(true))
}
}
}
Loading

0 comments on commit 929eefe

Please sign in to comment.