-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used common media picker options view and action sheet
- Loading branch information
1 parent
d89c3a6
commit a485008
Showing
12 changed files
with
83 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters