-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Feature: Settings stuff (Not auth related)
- Loading branch information
Showing
11 changed files
with
209 additions
and
54 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,5 @@ import Firebase | |
|
||
@MainActor | ||
class EditProfileViewModel: ObservableObject { | ||
|
||
} |
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,35 @@ | ||
// | ||
// ImagePicker.swift | ||
// ScribbleLab | ||
// | ||
// Created by Nevio Hirani on 03.11.23. | ||
// | ||
|
||
import SwiftUI | ||
import PhotosUI | ||
|
||
@MainActor | ||
class ImagePicker: ObservableObject { | ||
@Published var image: Image? | ||
@Published var imageSelection: PhotosPickerItem? { | ||
didSet { | ||
if let imageSelection { | ||
Task { try await loadTransferable(from: imageSelection) } | ||
} | ||
} | ||
} | ||
|
||
func loadTransferable(from imageSelection: PhotosPickerItem?) async throws { | ||
print("DEBUG: \(Image.transferRepresentation)") | ||
do { | ||
if let data = try await imageSelection?.loadTransferable(type: Data.self) { | ||
if let uiImage = UIImage(data: data) { | ||
self.image = Image(uiImage: uiImage) | ||
} | ||
} | ||
} catch { | ||
print("DEBUG: Profile picture selection and loading failed with error:\(error.localizedDescription)") | ||
image = nil | ||
} | ||
} | ||
} |
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,57 @@ | ||
// | ||
// CropView.swift | ||
// ScribbleLab | ||
// | ||
// Created by Nevio Hirani on 04.11.23. | ||
// Copyright © 2023 - 2024 ScribbleLabApp. All rights reserved. | ||
// Restricted use for ScribbleLab only. | ||
// | ||
|
||
import SwiftUI | ||
|
||
// MARK: Crop config | ||
/// An enum that is used for croping images and has 4 diffrent cases: | ||
/// - Circle: Circular cropping **for Profile Images** | ||
/// - Rectangle: For Rectangular cropping e.g. normal img in the editor, ... | ||
/// - square: For squareable cropping | ||
/// - custom: A CGSize is needed to use this case | ||
/// | ||
/// In order to use the custom modifier you have to declare cGSize as a let first: | ||
/// ```swift | ||
/// switch self { | ||
/// case .custom(let cGSize): | ||
/// } | ||
/// ``` | ||
/// | ||
/// The enum is reusable and can be used everywhere in this application where you work with ImagePickerItems. | ||
/// | ||
/// The crop config enum uses two functions: | ||
/// - ```name()``` | ||
/// - ```size()``` | ||
/// | ||
enum Crop: Equatable { | ||
case circle | ||
case rectangle | ||
case square | ||
case custom(CGSize) | ||
|
||
/// A function that returns a String value which contains the name of the case which will be displayed in an action everytime you select an image. | ||
func name() -> String { | ||
switch self { | ||
case .circle: return "Cricle" | ||
case .rectangle: return "Rectangle" | ||
case .square: return "Square" | ||
case .custom(let cGSize): return "Custom \(Int(cGSize.width)) x \(Int(cGSize.height))" | ||
} | ||
} | ||
|
||
/// A function that returns a CGSize value which contains the size of the case. It's needed for the actual cropping of the image | ||
func size() -> CGSize { | ||
switch self { | ||
case .circle: return .init(width: 150, height: 150) | ||
case .rectangle: return .init(width: 300, height: 500) | ||
case .square: return.init(width: 300, height: 300) | ||
case .custom(let cGSize): return cGSize | ||
} | ||
} | ||
} |
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
Oops, something went wrong.