Skip to content

Commit

Permalink
Add contact support
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-amisha-i authored Jan 10, 2025
1 parent c0283ce commit 6bfeb73
Show file tree
Hide file tree
Showing 46 changed files with 1,131 additions and 542 deletions.
12 changes: 8 additions & 4 deletions BaseStyle/BaseStyle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
211BCF222D2C071A001F4679 /* MultiMediaSelectionPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211BCF212D2C071A001F4679 /* MultiMediaSelectionPickerView.swift */; };
213A1F2A2C52335D00BF9800 /* CheckmarkButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 213A1F292C52335D00BF9800 /* CheckmarkButton.swift */; };
213F377E2C416C9C00972316 /* ScrollToTopButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 213F377D2C416C9C00972316 /* ScrollToTopButton.swift */; };
2163D3B82D27B2FD004B4F20 /* MediaPickerOptionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2163D3B72D27B2FD004B4F20 /* MediaPickerOptionsView.swift */; };
217620462C4F7CE700FED0D4 /* BackButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 217620452C4F7CE700FED0D4 /* BackButton.swift */; };
2176204A2C521EDF00FED0D4 /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 217620492C521EDF00FED0D4 /* RadioButton.swift */; };
219F43D92CCA4A7000729C67 /* RestoreButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 219F43D82CCA4A7000729C67 /* RestoreButton.swift */; };
Expand All @@ -27,7 +29,6 @@
D8302D9C2B9EE1D2005ACA13 /* PrimaryFloatingButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8302D9B2B9EE1D2005ACA13 /* PrimaryFloatingButton.swift */; };
D887213F2B99992A009DC5BE /* LoaderViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D887213E2B99992A009DC5BE /* LoaderViewModel.swift */; };
D89C933F2BC3C0F800FACD16 /* ForwardIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = D89C933E2BC3C0F800FACD16 /* ForwardIcon.swift */; };
D89C93462BC42DE500FACD16 /* MailComposeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D89C93452BC42DE500FACD16 /* MailComposeView.swift */; };
D89DBE332B888F2D00E5F1BD /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = D89DBE322B888F2D00E5F1BD /* SearchBar.swift */; };
D89DBE352B88A05F00E5F1BD /* UIApplication+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D89DBE342B88A05F00E5F1BD /* UIApplication+Extension.swift */; };
D89DBE3E2B8C67CE00E5F1BD /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D89DBE3D2B8C67CE00E5F1BD /* String+Extension.swift */; };
Expand Down Expand Up @@ -69,8 +70,10 @@

/* Begin PBXFileReference section */
174198EE4AF2FC82DADEB060 /* Pods_BaseStyle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BaseStyle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
211BCF212D2C071A001F4679 /* MultiMediaSelectionPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiMediaSelectionPickerView.swift; sourceTree = "<group>"; };
213A1F292C52335D00BF9800 /* CheckmarkButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckmarkButton.swift; sourceTree = "<group>"; };
213F377D2C416C9C00972316 /* ScrollToTopButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollToTopButton.swift; sourceTree = "<group>"; };
2163D3B72D27B2FD004B4F20 /* MediaPickerOptionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaPickerOptionsView.swift; sourceTree = "<group>"; };
217620452C4F7CE700FED0D4 /* BackButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackButton.swift; sourceTree = "<group>"; };
217620492C521EDF00FED0D4 /* RadioButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = "<group>"; };
219F43D82CCA4A7000729C67 /* RestoreButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestoreButton.swift; sourceTree = "<group>"; };
Expand All @@ -90,7 +93,6 @@
D8302D9B2B9EE1D2005ACA13 /* PrimaryFloatingButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimaryFloatingButton.swift; sourceTree = "<group>"; };
D887213E2B99992A009DC5BE /* LoaderViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LoaderViewModel.swift; path = BaseStyle/Views/LoaderViewModel.swift; sourceTree = SOURCE_ROOT; };
D89C933E2BC3C0F800FACD16 /* ForwardIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForwardIcon.swift; sourceTree = "<group>"; };
D89C93452BC42DE500FACD16 /* MailComposeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailComposeView.swift; sourceTree = "<group>"; };
D89DBE322B888F2D00E5F1BD /* SearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = "<group>"; };
D89DBE342B88A05F00E5F1BD /* UIApplication+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+Extension.swift"; sourceTree = "<group>"; };
D89DBE3D2B8C67CE00E5F1BD /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -303,9 +305,10 @@
D89DBE322B888F2D00E5F1BD /* SearchBar.swift */,
D8D42AAF2B872E44009B345D /* LoaderView.swift */,
D8D14A4F2BA090F000F45FF2 /* ShareSheetView.swift */,
D89C93452BC42DE500FACD16 /* MailComposeView.swift */,
D82174BD2BBAD86D00DB42C3 /* ProfileImageView.swift */,
D8E244C02B986CD800C6C82A /* ImagePickerView.swift */,
211BCF212D2C071A001F4679 /* MultiMediaSelectionPickerView.swift */,
2163D3B72D27B2FD004B4F20 /* MediaPickerOptionsView.swift */,
);
path = CustomUI;
sourceTree = "<group>";
Expand Down Expand Up @@ -515,12 +518,13 @@
D8D42AAC2B872A7C009B345D /* ToastView.swift in Sources */,
217620462C4F7CE700FED0D4 /* BackButton.swift in Sources */,
D8EB5E952CF8B12B005B68D9 /* ZoomableImageView.swift in Sources */,
211BCF222D2C071A001F4679 /* MultiMediaSelectionPickerView.swift in Sources */,
D8D42A952B85F8A2009B345D /* Bundle+Extension.swift in Sources */,
21D26E232CA199630090488B /* CapsuleButton.swift in Sources */,
D89C93462BC42DE500FACD16 /* MailComposeView.swift in Sources */,
213A1F2A2C52335D00BF9800 /* CheckmarkButton.swift in Sources */,
D8E244C12B986CD800C6C82A /* ImagePickerView.swift in Sources */,
D8D42A862B85D08F009B345D /* Font+Extension.swift in Sources */,
2163D3B82D27B2FD004B4F20 /* MediaPickerOptionsView.swift in Sources */,
D8EB0ED82CAD8C9F00AC6A44 /* ErrorView.swift in Sources */,
D8D42A992B870961009B345D /* AlertPrompt.swift in Sources */,
2176204A2C521EDF00FED0D4 /* RadioButton.swift in Sources */,
Expand Down
6 changes: 4 additions & 2 deletions BaseStyle/BaseStyle/CustomUI/Buttons/DismissButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ import SwiftUI

public struct DismissButton: View {

private let iconName: String
private let iconSize: (CGFloat, weight: Font.Weight)
private let padding: (horizontal: CGFloat, vertical: CGFloat)
private let borderColor: Color
private let foregroundColor: Color
private let backgroundColor: Color?
private let onDismissAction: (() -> Void)?

public init(iconSize: (CGFloat, weight: Font.Weight) = (24, .regular),
public init(iconName: String = "multiply", iconSize: (CGFloat, weight: Font.Weight) = (24, .regular),
padding: (horizontal: CGFloat, vertical: CGFloat) = (0, 0),
borderColor: Color = .clear, foregroundColor: Color = secondaryText,
backgroundColor: Color? = nil, onDismissAction: (() -> Void)? = nil) {
self.iconName = iconName
self.iconSize = iconSize
self.padding = padding
self.borderColor = borderColor
Expand All @@ -32,7 +34,7 @@ public struct DismissButton: View {
Button(action: {
onDismissAction?()
}, label: {
Image(systemName: "multiply")
Image(systemName: iconName)
.font(.system(size: iconSize.0).weight(iconSize.weight))
.foregroundStyle(foregroundColor)
.padding(.horizontal, padding.horizontal)
Expand Down
71 changes: 0 additions & 71 deletions BaseStyle/BaseStyle/CustomUI/MailComposeView.swift

This file was deleted.

51 changes: 51 additions & 0 deletions BaseStyle/BaseStyle/CustomUI/MediaPickerOptionsView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// MediaPickerOptionsView.swift
// BaseStyle
//
// Created by Nirali Sonani on 03/01/25.
//

import SwiftUI

public struct MediaPickerOptionsView: View {

public let image: UIImage?
public let imageUrl: String?
public let withRemoveAllOption: Bool

public let handleActionSelection: (ActionsOfSheet) -> Void

public init(image: UIImage? = nil, imageUrl: String? = nil, withRemoveAllOption: Bool = false,
handleActionSelection: @escaping (ActionsOfSheet) -> Void) {
self.image = image
self.imageUrl = imageUrl
self.withRemoveAllOption = withRemoveAllOption
self.handleActionSelection = handleActionSelection
}

public var body: some View {
if !withRemoveAllOption {
Button("Take a picture") {
handleActionSelection(.camera)
}
}

Button(withRemoveAllOption ? "Gallery" : "Choose from Library") {
handleActionSelection(.gallery)
}

if withRemoveAllOption || (image != nil || (imageUrl != nil && !(imageUrl?.isEmpty ?? false))) {
Button(withRemoveAllOption ? "Remove all" : "Remove", role: .destructive) {
handleActionSelection(withRemoveAllOption ? .removeAll : .remove)
}
}
}
}

// MARK: - Media Picker Action sheet
public enum ActionsOfSheet {
case camera
case gallery
case remove
case removeAll
}
114 changes: 114 additions & 0 deletions BaseStyle/BaseStyle/CustomUI/MultiMediaSelectionPickerView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//
// MultiMediaSelectionPickerView.swift
// Splito
//
// Created by Nirali Sonani on 06/01/25.
//

import SwiftUI
import PhotosUI

public struct MultiMediaSelectionPickerView: UIViewControllerRepresentable {

@Binding var isPresented: Bool

let attachmentLimit: Int
let onDismiss: ([Attachment]) -> Void

public init(isPresented: Binding<Bool>, attachmentLimit: Int, onDismiss: @escaping ([Attachment]) -> Void) {
self._isPresented = isPresented
self.attachmentLimit = attachmentLimit
self.onDismiss = onDismiss
}

public func makeUIViewController(context: Context) -> PHPickerViewController {
var configuration = PHPickerConfiguration()
configuration.selectionLimit = attachmentLimit
let picker = PHPickerViewController(configuration: configuration)
picker.delegate = context.coordinator
picker.view.tintColor = UIColor(infoColor)
return picker
}

public func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) {
// Nothing to update here
}

public func makeCoordinator() -> MultiMediaSelectionPickerCoordinator {
MultiMediaSelectionPickerCoordinator(isPresented: $isPresented, onDismiss: onDismiss)
}

public class MultiMediaSelectionPickerCoordinator: NSObject, PHPickerViewControllerDelegate {

@Binding var isPresented: Bool

let onDismiss: ([Attachment]) -> Void

let imageRequestOptions = PHImageRequestOptions()

public init(isPresented: Binding<Bool>, onDismiss: @escaping ([Attachment]) -> Void) {
self._isPresented = isPresented
self.onDismiss = onDismiss
}

public func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
imageRequestOptions.isSynchronous = true
var attachments: [Attachment] = []
let dispatchGroup = DispatchGroup()

results.forEach { attachment in
dispatchGroup.enter()

if attachment.itemProvider.canLoadObject(ofClass: UIImage.self) {
attachment.itemProvider.loadObject(ofClass: UIImage.self) { newImage, error in
if let selectedImage = newImage as? UIImage, let fileName = attachment.itemProvider.suggestedName {
let imageObject = Attachment(image: selectedImage.resizeImageIfNeededWhilePreservingAspectRatio(), name: fileName)
attachments.append(imageObject)
} else if let error = error {
print("MultiMediaSelectionPickerCoordinator: \(#function) Error in loading image: \(error)")
}
dispatchGroup.leave()
}
} else if attachment.itemProvider.hasItemConformingToTypeIdentifier(UTType.movie.identifier) {
attachment.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.movie.identifier) { url, error in // it will return the temporary file address, so immediately retrieving video as data from the temporary url.
if let url = url, let fileName = attachment.itemProvider.suggestedName {
do {
let data = try Data(contentsOf: url)
let videoObject = Attachment(videoData: data, video: url, name: fileName)
attachments.append(videoObject)
try? FileManager.default.removeItem(at: url) // Clean up temporary file
} catch {
print("MultiMediaSelectionPickerCoordinator: \(#function) Error loading data from URL: \(error)")
}
} else if let error {
print("MultiMediaSelectionPickerCoordinator: \(#function) Error in loading video: \(error)")
}
dispatchGroup.leave()
}
}
}

dispatchGroup.notify(queue: .main) {
self.isPresented = false
self.onDismiss(attachments)
}
}
}
}

// MARK: - Struct to hold attachment data
public struct Attachment {
public var id = UUID().uuidString
public var image: UIImage?
public var videoData: Data?
public var video: URL?
public var name: String

public init(id: String = UUID().uuidString, image: UIImage? = nil, videoData: Data? = nil, video: URL? = nil, name: String) {
self.id = id
self.image = image
self.videoData = videoData
self.video = video
self.name = name
}
}
7 changes: 7 additions & 0 deletions BaseStyle/BaseStyle/Extension/UIImage+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ public extension UIImage {
}
}
}

// Converts the UIImage to JPEG data with the highest quality
public extension UIImage {
var jpegRepresentationData: Data? {
self.jpegData(compressionQuality: 1.0)
}
}
1 change: 1 addition & 0 deletions BaseStyle/BaseStyle/Resource/AppColors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ public let disableText = Color.disableText
public let inverseDisableText = Color.inverseDisableText

public let secondaryText = Color.secondaryText
public let secondaryLightText = Color.secondaryLightText
public let lowestText = Color.lowestText
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x61",
"green" : "0x61",
"red" : "0xFF"
}
},
"idiom" : "universal"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.600",
"blue" : "0x00",
"green" : "0x00",
"red" : "0x00"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 6bfeb73

Please sign in to comment.