Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/importing images #111

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Kabinett/Application/KabinettApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ import FirebaseFirestore
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// FirebaseApp.configure()
//// Uncomment these blocks to use Firebase Emulator Suite
// #if DEBUG
// // Firebase Authenticate Emulator
// Auth.auth().useEmulator(withHost:"localhost", port:9099)
//
// // Firebase Storage Emulator
// Storage.storage().useEmulator(withHost: "localhost", port: 9199)
//
// // Firebaes Firestore Emulator
// let settings = Firestore.firestore().settings
// settings.host = "localhost:8080"
// settings.isSSLEnabled = false
// Firestore.firestore().settings = settings
// #endif
FirebaseApp.configure()
// Uncomment these blocks to use Firebase Emulator Suite
#if DEBUG
// Firebase Authenticate Emulator
Auth.auth().useEmulator(withHost:"localhost", port:9099)

// Firebase Storage Emulator
Storage.storage().useEmulator(withHost: "localhost", port: 9199)

// Firebaes Firestore Emulator
let settings = Firestore.firestore().settings
settings.host = "localhost:8080"
settings.isSSLEnabled = false
Firestore.firestore().settings = settings
#endif

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ struct CustomTabBar: View {

var body: some View {
GeometryReader { geometry in
ZStack {
HStack(spacing: 0) {
tabItem(image: viewModel.envelopeImage, tag: 0)
.position(x: geometry.size.width * 0.25, y: geometry.size.height * 0.5)
.frame(width: geometry.size.width / 3)

tabItem(image: viewModel.plusImage, tag: 1)
.position(x: geometry.size.width * 0.5, y: geometry.size.height * 0.5)
.frame(width: geometry.size.width / 3)

tabItem(image: viewModel.profileImage, tag: 2)
.position(x: geometry.size.width * 0.75, y: geometry.size.height * 0.5)
.frame(width: geometry.size.width / 3)
}
.frame(width: geometry.size.width, height: geometry.size.height)
.position(x: geometry.size.width / 2, y: geometry.size.height / 2)
.frame(width: geometry.size.width, height: 44)
.background(Color.clear)
.position(x: geometry.size.width / 2, y: geometry.size.height - 22)
}
.frame(height: 20)
}

private func tabItem(image: UIImage, tag: Int) -> some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct CustomTabView: View {
@State private var paths: [NavigationPath] = [NavigationPath(), NavigationPath(), NavigationPath()]

var body: some View {
ZStack {
ZStack(alignment: .bottom) {
TabView(selection: $viewModel.selectedTab) {
NavigationStack(path: $paths[0]) {
LetterBoxView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ import SwiftUI

struct ImportDialog: View {
@EnvironmentObject var viewModel: CustomTabViewModel

var body: some View {
EmptyView()
.confirmationDialog("νŽΈμ§€λ₯Ό 뢈러올 방법을 μ„ νƒν•˜μ„Έμš”.", isPresented: $viewModel.showImportDialog, titleVisibility: .visible) {
Button("μ΄¬μ˜ν•˜κΈ°") {
viewModel.hideOptions()
viewModel.showCamera = true
}
Button("μ•¨λ²”μ—μ„œ κ°€μ Έμ˜€κΈ°") {
viewModel.hideOptions()
viewModel.showPhotoLibrary = true
}
Button("μ·¨μ†Œ", role: .cancel) {
viewModel.showOptions = true
viewModel.showImportDialog = false
viewModel.showOptions = true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ import SwiftUI

struct OptionOverlay: View {
@EnvironmentObject var viewModel: CustomTabViewModel

@State private var letterContent = LetterWriteModel()
@State var letterContent = LetterWriteModel()

@State private var isWritingLetter = false

var body: some View {
ZStack {
Color.black.opacity(0.5)
.edgesIgnoringSafeArea(.all)
.onTapGesture {
withAnimation() {
withAnimation {
viewModel.hideOptions()
}
}
Expand All @@ -31,6 +28,7 @@ struct OptionOverlay: View {
HStack(spacing: 2) {
Button(action: {
viewModel.showImportDialogAndHideOptions()
viewModel.hideOptions()
}) {
Text("νŽΈμ§€ 뢈러였기")
.font(.system(size: 14))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,17 @@ final class ImagePickerViewModel: ObservableObject {

@MainActor
func fetchCurrentWriter() async {
let result = await firebaseFirestoreManager.getCurrentWriter()
self.fromUser = result
self.fromUserName = result.name
self.userKabiNumber = String(format: "%06d", result.kabinettNumber)
self.fromUserId = result.id
updateCurrentUser()
var letterContent = LetterWriteModel()
updateSelectedUser(&letterContent, selectedUserName: result.name)
let publisher = await firebaseFirestoreManager.getCurrentWriter()
for await result in publisher.values {
self.fromUser = result
self.fromUserName = result.name
self.userKabiNumber = String(format: "%06d", result.kabinettNumber)
self.fromUserId = result.id
updateCurrentUser()
var letterContent = LetterWriteModel()
updateSelectedUser(&letterContent, selectedUserName: result.name)
break
}
}

// MARK: - Image Loading
Expand Down
Loading