diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.swift b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.swift deleted file mode 100644 index 1740ec4..0000000 --- a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.swift +++ /dev/null @@ -1,9 +0,0 @@ -// -// LocalMedia.swift -// SBDesign -// -// Created by dogukaan on 21.01.2024. -// Copyright © 2024 SwiftBuddies. All rights reserved. -// - -import Foundation diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesBlue.colorset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesBlue.colorset/Contents.json new file mode 100644 index 0000000..2210492 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesBlue.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xBA", + "green" : "0x88", + "red" : "0x13" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xBA", + "green" : "0x88", + "red" : "0x13" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesDarkGray.colorset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesDarkGray.colorset/Contents.json new file mode 100644 index 0000000..fc5933c --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesDarkGray.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x4D", + "green" : "0x42", + "red" : "0x45" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x4D", + "green" : "0x42", + "red" : "0x45" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesGray.colorset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesGray.colorset/Contents.json new file mode 100644 index 0000000..0e7b168 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesGray.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x66", + "green" : "0x66", + "red" : "0x66" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x66", + "green" : "0x66", + "red" : "0x66" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesWhite.colorset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesWhite.colorset/Contents.json new file mode 100644 index 0000000..f46b959 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/BuddiesWhite.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xE7", + "green" : "0xE5", + "red" : "0xE3" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xE7", + "green" : "0xE5", + "red" : "0xE3" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/buddiesOrange.colorset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/buddiesOrange.colorset/Contents.json new file mode 100644 index 0000000..90a2491 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/buddiesOrange.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x33", + "green" : "0x69", + "red" : "0xF3" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x33", + "green" : "0x69", + "red" : "0xF3" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/buddiesTeal.colorset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/buddiesTeal.colorset/Contents.json new file mode 100644 index 0000000..066340a --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/buddiesTeal.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x9E", + "green" : "0x98", + "red" : "0x03" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x9E", + "green" : "0x98", + "red" : "0x03" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/buddiesYellow.colorset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/buddiesYellow.colorset/Contents.json new file mode 100644 index 0000000..331ee24 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Colors/buddiesYellow.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x2C", + "green" : "0xA2", + "red" : "0xF2" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x2C", + "green" : "0xA2", + "red" : "0xF2" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/SwiftBuddiesHeader.imageset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/SwiftBuddiesHeader.imageset/Contents.json similarity index 100% rename from SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/SwiftBuddiesHeader.imageset/Contents.json rename to SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/SwiftBuddiesHeader.imageset/Contents.json diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/SwiftBuddiesHeader.imageset/SwiftBuddiesHeader.jpeg b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/SwiftBuddiesHeader.imageset/SwiftBuddiesHeader.jpeg similarity index 100% rename from SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/SwiftBuddiesHeader.imageset/SwiftBuddiesHeader.jpeg rename to SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/SwiftBuddiesHeader.imageset/SwiftBuddiesHeader.jpeg diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/example.imageset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/example.imageset/Contents.json new file mode 100644 index 0000000..264361e --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/example.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "example.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/example.imageset/example.png b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/example.imageset/example.png new file mode 100644 index 0000000..f1e0f79 Binary files /dev/null and b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/example.imageset/example.png differ diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/logo.imageset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/logo.imageset/Contents.json new file mode 100644 index 0000000..5f670ca --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/logo.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "logo.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/logo.imageset/logo.png b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/logo.imageset/logo.png new file mode 100644 index 0000000..1c5f215 Binary files /dev/null and b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/logo.imageset/logo.png differ diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/timcook.imageset/Contents.json b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/timcook.imageset/Contents.json new file mode 100644 index 0000000..dc32d04 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/timcook.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "timcook.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/timcook.imageset/timcook.jpg b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/timcook.imageset/timcook.jpg new file mode 100644 index 0000000..e9720ed Binary files /dev/null and b/SwiftBuddiesIOS/Targets/DesignModule/Resources/Media/LocalMedia.xcassets/Feed/timcook.imageset/timcook.jpg differ diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/ActionButtonView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/ActionButtonView.swift new file mode 100644 index 0000000..ec9dc7c --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/ActionButtonView.swift @@ -0,0 +1,60 @@ +// +// ActionButtonView.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI +import Design + +struct ActionButtonView: View { + + @State private var isLiked = false + @State private var showComments = false + @State private var isSaved = false + + var body: some View { + HStack { + Spacer() + Button { + isLiked.toggle() + } label: { + Text("Like") + } + .buttonStyle(.like(isLiked)) + Spacer() + + Button { + showComments.toggle() + } label: { + Text("Comments") + } + .buttonStyle(.comment) + Spacer() + + Button { + isSaved.toggle() + } label: { + Text("Save") + } + .buttonStyle(.save(isSaved)) + + Button { + + } label: { + + } + .buttonStyle(/*@START_MENU_TOKEN@*//*@PLACEHOLDER=Button Style@*/DefaultButtonStyle()/*@END_MENU_TOKEN@*/) + Spacer() + } + .padding(.top, 4) + .padding([.bottom, .horizontal], 10) + .foregroundColor(.gray) + } +} + +//#Preview { +// ActionButtonView() +//} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/AddPhotoButton.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/AddPhotoButton.swift new file mode 100644 index 0000000..8cba9d0 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/AddPhotoButton.swift @@ -0,0 +1,60 @@ +// +// AddPhotoButton.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI + +struct AddPhotoButton: View { + @Binding var isCameraViewPresented: Bool + @Binding var imagePickerPresented: Bool + @ObservedObject var viewModel: AddPostViewModel + + var body: some View { + HStack { + Button(action: { + isCameraViewPresented.toggle() + }) { + Image(systemName: "camera.fill") + .foregroundColor(.gray) + .imageScale(.large) + .frame(width: 50, height: 50) + .background( + RoundedRectangle(cornerRadius: 10) + .fill(Color.white) + .overlay( + RoundedRectangle(cornerRadius: 10) + .stroke(Color.cyan, lineWidth: 2) + ) + ) + } + .fullScreenCover(isPresented: $isCameraViewPresented) { + CameraView() + } + Button(action: { + imagePickerPresented.toggle() + }) { + Image(systemName: "photo.badge.plus") + .foregroundColor(.gray) + .imageScale(.large) + .frame(width: 50, height: 50) + .background( + RoundedRectangle(cornerRadius: 10) + .fill(Color.white) + .overlay( + RoundedRectangle(cornerRadius: 10) + .stroke(Color.cyan, lineWidth: 2) + ) + ) + } + .photosPicker(isPresented: $imagePickerPresented, selection: $viewModel.selectedImage) + } + } +} + +//#Preview { +// AddPhotoButton() +//} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/AddPostContentView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/AddPostContentView.swift new file mode 100644 index 0000000..17a0c82 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/AddPostContentView.swift @@ -0,0 +1,72 @@ +// +// AddPostContentView.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI + +struct AddPostContentView: View { + @ObservedObject var viewModel: AddPostViewModel + @Binding var imagePickerPresented: Bool + @State private var customTF = "" + let placeholder = "What is new?" + + var body: some View { + ScrollView { + VStack { + + // MARK: - Message + + TextEditor(text: $customTF) + .foregroundColor(customTF.isEmpty ? .gray : .primary) + .overlay( + customTF.isEmpty ? Text(placeholder).foregroundColor(.gray).padding(.all, 4) : nil, alignment: .topLeading + ) + .padding() + .frame(minHeight: 100) + + // MARK: - Image + + if let image = viewModel.postImage { + ZStack(alignment: .topTrailing) { + image + .resizable() + .scaledToFit() + .frame(maxWidth: 300, maxHeight: 250) + .clipped() + + HStack { + Button(action: { + imagePickerPresented.toggle() + }) { + Image(systemName: "pencil.circle.fill") + + .imageScale(.large) + .symbolRenderingMode(.palette) + .foregroundStyle(Color.white, Color.cyan) + } + + Button(action: { + viewModel.postImage = nil + }) { + Image(systemName: "xmark.circle.fill") + + .imageScale(.large) + .symbolRenderingMode(.palette) + .foregroundStyle(Color.white, Color.cyan) + } + } + .padding([.top, .trailing], 10) + } + } + } + } + } +} + +//#Preview { +// AddPostContentView() +//} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/AddPostHeaderButtonsView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/AddPostHeaderButtonsView.swift new file mode 100644 index 0000000..6841af8 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/AddPostHeaderButtonsView.swift @@ -0,0 +1,41 @@ +// +// AddPostHeaderButtonsView.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI + +struct AddPostHeaderButtonsView: View { + + @Environment(\.presentationMode) var presentationMode + + var body: some View { + + HStack { + Button { + self.presentationMode.wrappedValue.dismiss() + } label: { + Image(systemName: "xmark.circle") + .imageScale(.large) + } + Spacer() + Button { + print("safe button pressed") + } label: { + Text("Post") + .font(.title2) + .fontWeight(.regular) + } + } + .padding(.horizontal, 20) + .padding(.top, 8) + .foregroundColor(.cyan) + } +} + +#Preview { + AddPostHeaderButtonsView() +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/CameraView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/CameraView.swift new file mode 100644 index 0000000..e4d84aa --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/Components/CameraView.swift @@ -0,0 +1,57 @@ +// +// CameraView.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI +import UIKit + +struct CameraView: UIViewControllerRepresentable { + + @State private var selectedImage: UIImage? + + class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate { + let parent: CameraView + + init(_ parent: CameraView) { + self.parent = parent + } + + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { + if let uiImage = info[.originalImage] as? UIImage { + parent.selectedImage = uiImage + } + + parent.presentationMode.wrappedValue.dismiss() + } + + func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { + parent.presentationMode.wrappedValue.dismiss() + } + } + + @Environment(\.presentationMode) var presentationMode + var sourceType: UIImagePickerController.SourceType = .camera + + func makeUIViewController(context: Context) -> UIImagePickerController { + let picker = UIImagePickerController() + picker.sourceType = sourceType + picker.delegate = context.coordinator + return picker + } + + func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) { + + } + + func makeCoordinator() -> Coordinator { + Coordinator(self) + } +} + +#Preview { + CameraView() +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/View/AddPostView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/View/AddPostView.swift new file mode 100644 index 0000000..ba3dc6e --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/View/AddPostView.swift @@ -0,0 +1,39 @@ +// +// AddPostView.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI +import PhotosUI + +struct AddPostView: View { + @State private var isCameraViewPresented = false + @State private var imagePickerPresented = false + @ObservedObject var viewModel = AddPostViewModel() + + var body: some View { + NavigationStack { + VStack { + AddPostHeaderButtonsView() + + Divider() + + AddPostContentView(viewModel: viewModel, + imagePickerPresented: $imagePickerPresented + ) + AddPhotoButton(isCameraViewPresented: $isCameraViewPresented, + imagePickerPresented: $imagePickerPresented, + viewModel: viewModel + ) + .padding(.vertical, 10) + } + } + } +} + +#Preview { + AddPostView() +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/ViewModel/AddPostViewModel.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/ViewModel/AddPostViewModel.swift new file mode 100644 index 0000000..7c06128 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/AddPost/ViewModel/AddPostViewModel.swift @@ -0,0 +1,28 @@ +// +// AddPostViewModel.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import PhotosUI +import SwiftUI + +@MainActor +class AddPostViewModel: ObservableObject { + + @Published var selectedImage: PhotosPickerItem? { + didSet { Task { await loadImage(fromItem:selectedImage) } } + } + + @Published var postImage: Image? + + func loadImage(fromItem item: PhotosPickerItem?) async { + guard let item = item else { return } + + guard let data = try? await item.loadTransferable(type: Data.self) else { return } + guard let uiImage = UIImage(data: data) else { return } + self.postImage = Image(uiImage: uiImage) + } +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/ButtonStyles/PostButtonStyle.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/ButtonStyles/PostButtonStyle.swift new file mode 100644 index 0000000..69a692c --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/ButtonStyles/PostButtonStyle.swift @@ -0,0 +1,142 @@ +// +// PostButtonStyle.swift +// SwiftBuddiesIOS +// +// Created by dogukaan on 18.05.2024. +// + +import SwiftUI + +public struct PostButtonStyle: ButtonStyle { + + public enum Style { + case like(Bool) + case comment + case save(Bool) + case addPost(AddPostType) + } + public enum AddPostType { + case icon + case text + } + let style: Style + + @Environment(\.isEnabled) var isEnabled: Bool + + public func makeBody(configuration: Configuration) -> some View { + buttonStyle(configuration: configuration) + } + + @ViewBuilder + func buttonStyle(configuration: Configuration) -> some View { + switch style { + case .like(let isToggled): + VStack(spacing: 2) { + Image(systemName: isToggled ? "heart.fill" : "heart") + .imageScale(.medium) + .foregroundColor( + (isToggled ? Color.red : Color.primary) + .opacity(configuration.isPressed ? 0.6 : 1) + ) + + configuration.label + .font(.caption2) + .foregroundColor( + (isToggled ? Color.red : Color.primary) + .opacity(configuration.isPressed ? 0.6 : 1) + ) + } + .frame(maxWidth: .infinity) + case .save(let isToggled): + VStack(spacing: 2) { + Image(systemName: isToggled ? "bookmark.fill" : "bookmark") + .imageScale(.medium) + .foregroundColor( + (isToggled ? Color.yellow : Color.primary) + .opacity(configuration.isPressed ? 0.6 : 1) + ) + + configuration.label + .font(.caption2) + .foregroundColor( + (isToggled ? Color.yellow : Color.primary) + .opacity(configuration.isPressed ? 0.6 : 1) + ) + } + .frame(maxWidth: .infinity) + case .comment: + VStack(spacing: 2) { + Image(systemName: "bubble.right") + .imageScale(.medium) + .foregroundColor(.primary.opacity(configuration.isPressed ? 0.6 : 1)) + + configuration.label + .font(.caption2) + .foregroundColor(.primary.opacity(configuration.isPressed ? 0.6 : 1)) + } + .frame(maxWidth: .infinity) + case .addPost(let type): + switch type { + case .icon: + Image(systemName: "plus.circle") + .imageScale(.medium) + .foregroundColor(.primary.opacity(configuration.isPressed ? 0.6 : 1)) + .frame(maxWidth: .infinity) + case .text: + configuration.label + .font(.caption2) + .foregroundColor(.primary.opacity(configuration.isPressed ? 0.6 : 1)) + .frame(maxWidth: .infinity) + } + } + } +} + + +#Preview(body: { + List { + Section { + Button { } label: { + Text("Login") + } + .buttonStyle(.like(true)) + } header: { Text("Primary fill") } + + Section { + Button { } label: { + Text("Login") + } + .buttonStyle(.save(false)) + } header: { Text("Secondary fill icon") } + + Section { + Button { } label: { + Text("Login") + } + .buttonStyle(.comment) + } header: { Text("Secondary fill") } + } +}) + +// MARK: - Extend the button style +extension ButtonStyle where Self == PostButtonStyle { + + public static var comment: PostButtonStyle { + PostButtonStyle(style: .comment) + } + + public static func like(_ isToggled: Bool) -> Self { + PostButtonStyle(style: .like(isToggled)) + } + + public static func save(_ isToggled: Bool) -> Self { + PostButtonStyle(style: .save(isToggled)) + } +} + +extension ButtonStyle where Self == PostButtonStyle { + public static func addPost(_ type: PostButtonStyle.AddPostType) -> Self { + PostButtonStyle(style: .addPost(type)) + } +} + diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/Comments/AddCommentView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Comments/AddCommentView.swift new file mode 100644 index 0000000..1beb6e2 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Comments/AddCommentView.swift @@ -0,0 +1,32 @@ +// +// AddCommentView.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI + +struct AddCommentView: View { + @State private var comment: String = "" + + var body: some View { + HStack{ + TextField("Add commment", text: $comment) + .textFieldStyle(RoundedBorderTextFieldStyle()) + + Button{ + print("Send comment") + } label: { + Image(systemName: "paperplane") + .imageScale(.medium) + } + } + .padding(20) + } +} + +#Preview { + AddCommentView() +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/Comments/CommentCell.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Comments/CommentCell.swift new file mode 100644 index 0000000..b1ffdc1 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Comments/CommentCell.swift @@ -0,0 +1,58 @@ +// +// CommentCell.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI + +struct CommentCell: View { + + let post: PostModel + var body: some View { + HStack(spacing: 8){ + if let user = post.user{ + + // MARK: - User photo + + Image(user.profileImageUrl) + .resizable() + .scaledToFill() + .frame(width: 35, height: 35) + .clipShape(Circle()) + VStack(spacing: 8){ + HStack(spacing: 8){ + + // MARK: - User name + + Text(user.name) + .font(.body) + .fontWeight(.medium) + + // MARK: - Time + + Text("1 h") //need add logic + .font(.body) + .fontWeight(.regular) + .foregroundColor(.gray) + Spacer() + } + + // MARK: - Comment + + Text("Here will be comment. Here will be comment. ") + .frame(maxWidth: .infinity, alignment: .leading) + } + Spacer() + } + } + .padding(.top, 10) + .padding(.horizontal, 10) + } +} + +//#Preview { +// CommentCell() +//} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/Comments/CommentView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Comments/CommentView.swift new file mode 100644 index 0000000..4699114 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Comments/CommentView.swift @@ -0,0 +1,39 @@ +// +// CommentView.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI + +struct CommentView: View { + + var body: some View { + NavigationStack{ + VStack{ + ScrollView{ + LazyVStack(spacing: 12) { + ForEach(PostModel.MockPosts) { post in + CommentCell(post: post) + } + } + .padding(.top, 20) + .padding(.horizontal, 12) + } + .navigationTitle("Comments") + .navigationBarTitleDisplayMode(.inline) + } + + AddCommentView() + } + .onTapGesture { + UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) + } + } +} + +#Preview { + CommentView() +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/Components/ActionButton.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Components/ActionButton.swift new file mode 100644 index 0000000..8871b29 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Components/ActionButton.swift @@ -0,0 +1,41 @@ +// +// ActionButton.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI + +struct ActionButton: View { + let action: () -> Void + let systemImageName: String + let label: String + let isToggled: Bool + let toggledColor: Color + + init(systemImageName: String, label: String, isToggled: Bool, toggledColor: Color, action: @escaping () -> Void) { + self.action = action + self.systemImageName = systemImageName + self.label = label + self.isToggled = isToggled + self.toggledColor = toggledColor + } + + var body: some View { + Button { + action() + } label: { + VStack(spacing: 2) { + Image(systemName: systemImageName) + .imageScale(.medium) + .foregroundColor(isToggled ? toggledColor : .primary) + + Text(label) + .font(.caption2) + .foregroundColor(isToggled ? toggledColor : .primary) + } + } + } +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/Feed.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Feed.swift deleted file mode 100644 index 9079295..0000000 --- a/SwiftBuddiesIOS/Targets/FeedModule/Sources/Feed.swift +++ /dev/null @@ -1,9 +0,0 @@ - -import SwiftUI - -public struct FeedView: View { - public init(){ } - public var body: some View { - Text("Feed") - } -} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCell.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCell.swift new file mode 100644 index 0000000..91ea7a1 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCell.swift @@ -0,0 +1,32 @@ +// +// FeedViewCell.swift +// Feed +// +// Created by Kate Kashko on 8.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI + +struct FeedCell: View { + let post: PostModel + + var body: some View { + + VStack { + FeedCellHeaderView(post: post) + FeedCellContentView(post: post) + FeedCellCountersView(post: post) + + Divider() + + ActionButtonView() + } + .background(Color.white) + .clipShape(RoundedRectangle(cornerRadius: 15)) + } +} + +#Preview { + FeedCell(post: PostModel.MockPosts[0]) +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCellContentView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCellContentView.swift new file mode 100644 index 0000000..4be7ad6 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCellContentView.swift @@ -0,0 +1,34 @@ +// +// FeedCellContentView.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI +import Design + +struct FeedCellContentView: View { + let post: PostModel + + var body: some View { + // MARK: - post message + Text(post.content) + .frame(maxWidth: .infinity, alignment: .leading) + .font(.footnote) + .padding(.horizontal, 10) + .padding(.top, 4) + + // MARK: - post image + if let image = post.imageUrl, !image.isEmpty { + Image(image, bundle: DesignResources.bundle) + .resizable() + .scaledToFit() + } + } +} + +#Preview { + FeedCellContentView(post: PostModel.MockPosts[0]) +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCellCountersView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCellCountersView.swift new file mode 100644 index 0000000..a5568e1 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCellCountersView.swift @@ -0,0 +1,38 @@ +// +// FeedCellCountersView.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI + +struct FeedCellCountersView: View { + let post: PostModel + + var body: some View { + HStack { + // MARK: - Like counter + Image(systemName: "heart") + + Text("\(post.likeCount)") + .font(.footnote) + .fontWeight(.medium) + .frame(maxWidth: .infinity, alignment: .leading) + + // MARK: - Comments counter + Text("\(post.commentsCount) comments") + .font(.footnote) + .fontWeight(.regular) + .frame(maxWidth: .infinity, alignment: .trailing) + } + .padding(.top, 8) + .padding(.horizontal, 10) + .foregroundColor(.gray) + } +} + +#Preview { + FeedCellCountersView(post: PostModel.MockPosts[0]) +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCellHeaderView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCellHeaderView.swift new file mode 100644 index 0000000..7e97cdf --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedCellHeaderView.swift @@ -0,0 +1,51 @@ +// +// FeedCellHeaderView.swift +// Feed +// +// Created by Kate Kashko on 15.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import SwiftUI +import Design + +struct FeedCellHeaderView: View { + let post: PostModel + + var body: some View { + HStack { + if let user = post.user { + // MARK: - User photo + Image(user.profileImageUrl, bundle: DesignResources.bundle) + .resizable() + .scaledToFill() + .frame(width: 43, height: 43) + .clipShape(Circle()) + + VStack { + // MARK: - User name + Text(user.name) + .font(.body) + .fontWeight(.medium) + .frame(maxWidth: .infinity, alignment: .leading) + + Spacer() + // MARK: - Date of publication of the post + Text("01.01.2025 at 09.00 a.m.") //need add logic + .font(.caption2) + .fontWeight(.regular) + .frame(maxWidth: .infinity, alignment: .leading) + .foregroundColor(.gray) + } + .frame(maxHeight: 43) + } + Spacer() + } + .padding(.top, 10) + .padding(.horizontal, 10) + } +} + +#Preview { + FeedCellHeaderView(post: PostModel.MockPosts[0]) +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedView.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedView.swift new file mode 100644 index 0000000..7cf9ea9 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/FeedView.swift @@ -0,0 +1,54 @@ +import SwiftUI +import Design + +public struct FeedView: View { + + @State private var addPost = false + + public init() {} + public var body: some View { + NavigationStack { + ScrollView { + LazyVStack(spacing: 10) { + ForEach(PostModel.MockPosts) { post in + FeedCell(post: post) + } + } + .padding(.top, 20) + .padding(.horizontal, 12) + } + .navigationTitle("Feed") + .navigationBarTitleDisplayMode(.inline) + + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + Image("logo", bundle: DesignResources.bundle) + .resizable() + .scaledToFill() + .frame(width: 100, height: 32) + } + ToolbarItem(placement: .navigationBarTrailing) { + Button(action: { + addPost.toggle() + }) { + Image(systemName: "plus.circle") + .resizable() + .renderingMode(.template) + .scaledToFill() + .frame(width: 24, height: 24) + .foregroundColor(Color.cyan) + } + } + } + // TODO: here will be custom color + .background(Color(CGColor(gray: 0.9, alpha: 0.5))) + .sheet(isPresented: $addPost) { + AddPostView() + } + } + } +} + +#Preview { + FeedView() +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/Model/PostModel.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Model/PostModel.swift new file mode 100644 index 0000000..b9ccc8b --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Model/PostModel.swift @@ -0,0 +1,52 @@ +// +// Post.swift +// Feed +// +// Created by Kate Kashko on 8.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import Foundation + +struct PostModel: Identifiable, Hashable, Codable { + let id: String + let authorId: String + let likeCount: Int + let commentsCount: Int + let content: String + let imageUrl: String? + var user: UserModel? +} + +extension PostModel { + static var MockPosts: [PostModel] = [ + .init( + id: NSUUID().uuidString, + authorId: NSUUID().uuidString, + likeCount: 98, + commentsCount: 10, + content: "Lets do it...", + imageUrl: "example", + user: UserModel.MockUsers[0] + ), + .init( + id: NSUUID().uuidString, + authorId: NSUUID().uuidString, + likeCount: 123, + commentsCount: 15, + content: "Hello everyone", + imageUrl: "", + user: UserModel.MockUsers[0] + ), + .init( + id: NSUUID().uuidString, + authorId: NSUUID().uuidString, + likeCount: 120, + commentsCount: 20, + content: "Our first steps in project...", + imageUrl: "logo", + user: UserModel.MockUsers[0] + ) + + ] +} diff --git a/SwiftBuddiesIOS/Targets/FeedModule/Sources/Model/UserModel.swift b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Model/UserModel.swift new file mode 100644 index 0000000..681c1e2 --- /dev/null +++ b/SwiftBuddiesIOS/Targets/FeedModule/Sources/Model/UserModel.swift @@ -0,0 +1,23 @@ +// +// User.swift +// Feed +// +// Created by Kate Kashko on 8.04.2024. +// Copyright © 2024 SwiftBuddies. All rights reserved. +// + +import Foundation + +struct UserModel: Identifiable, Hashable, Codable { + let id: String + let name: String + let profileImageUrl: String +} + +extension UserModel { + static var MockUsers: [UserModel] = [ + .init(id: NSUUID().uuidString, name: "Tim Cook", profileImageUrl: "timcook"), + .init(id: NSUUID().uuidString, name: "Tim Cook", profileImageUrl: "timcook"), + .init(id: NSUUID().uuidString, name: "Tim Cook", profileImageUrl: "timcook") + ] +} diff --git a/SwiftBuddiesIOS/Targets/LoginModule/Sources/ViewModels/AuthenticationViewModel.swift b/SwiftBuddiesIOS/Targets/LoginModule/Sources/ViewModels/AuthenticationViewModel.swift index 9b0e22f..120d939 100644 --- a/SwiftBuddiesIOS/Targets/LoginModule/Sources/ViewModels/AuthenticationViewModel.swift +++ b/SwiftBuddiesIOS/Targets/LoginModule/Sources/ViewModels/AuthenticationViewModel.swift @@ -13,6 +13,7 @@ final public class AuthenticationViewModel: ObservableObject { public init() { self.authManager = AuthenticationManager(authService: .shared) self.apiClient = .shared + self.authManager = AuthenticationManager(authService: .shared) } func signIn(provider: AuthProviderOption) throws {