Skip to content

Commit

Permalink
removed not working camera feature; added debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrcc committed Jan 13, 2024
1 parent 79946ce commit 1a5e1b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 71 deletions.
23 changes: 19 additions & 4 deletions notes-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1500;
LastUpgradeCheck = 1520;
TargetAttributes = {
95BA48E12AE3D5B000552282 = {
CreatedOnToolsVersion = 15.0.1;
Expand Down Expand Up @@ -307,6 +307,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down Expand Up @@ -368,6 +369,7 @@
DEVELOPMENT_ASSET_PATHS = "\"notes-ios/Preview Content\"";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = Notes;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand All @@ -380,9 +382,12 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "at.fhj.ims23.notes-ios";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
};
name = "Privacy - Camera ";
};
Expand All @@ -391,6 +396,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down Expand Up @@ -454,6 +460,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down Expand Up @@ -515,6 +522,7 @@
DEVELOPMENT_ASSET_PATHS = "\"notes-ios/Preview Content\"";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = Notes;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand All @@ -527,9 +535,12 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "at.fhj.ims23.notes-ios";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
};
Expand All @@ -543,6 +554,7 @@
DEVELOPMENT_ASSET_PATHS = "\"notes-ios/Preview Content\"";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = Notes;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand All @@ -555,9 +567,12 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "at.fhj.ims23.notes-ios";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
};
Expand Down
1 change: 1 addition & 0 deletions notes-ios/core/model/ViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ViewModel: ObservableObject {
@Published var notes: [Note] = []
private var repo: NotesRepository


init(repo: NotesRepository) {
self.repo = repo
}
Expand Down
71 changes: 4 additions & 67 deletions notes-ios/ui/views/NoteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ struct NoteView: View {
@ObservedObject var viewModel: ViewModel

@State private var selectedPhotos = [PhotosPickerItem]()
@State private var showCamera = false
@State private var selectedImage: UIImage?

var body: some View {
NavigationStack {
VStack(alignment: .leading) {
Expand Down Expand Up @@ -49,11 +48,11 @@ struct NoteView: View {
.onChange(of: selectedPhotos) { _, result in
note.images.removeAll()
Task {
print("CHANGE PHOTOS")
for photo in selectedPhotos {
do {
if let data = try await photo.loadTransferable(type: Data.self) {
if let uiImage = UIImage(data: data) {

note.images.append(data)
}
}
Expand All @@ -65,7 +64,7 @@ struct NoteView: View {
}
.onDisappear {
Task {
print(note.text)
print("PERSIST IN ON DISAPPEAR")
await self.viewModel.persist()
}
}
Expand All @@ -85,7 +84,7 @@ struct NoteView: View {
Task {
let url = URL(string: "https://api.api-ninjas.com/v1/quotes")
let api: BaseApi = BaseApi()
let response: Result<[Quote], ApiError> = try await api.sendRequest(
let response: Result<[Quote], ApiError> = await api.sendRequest(
url: url,
apiKey: "apikey", // TODO use environment
responseModel: [Quote].self
Expand All @@ -109,66 +108,4 @@ struct NoteView: View {
}
}
}

var isAuthorized: Bool {
get async {
let status = AVCaptureDevice.authorizationStatus(for: .video)

// Determine if the user previously authorized camera access.
var isAuthorized = status == .authorized

// If the system hasn't determined the user's authorization status,
// explicitly prompt them for approval.
if status == .notDetermined {
isAuthorized = await AVCaptureDevice.requestAccess(for: .video)
}

return isAuthorized
}
}


func setUpCaptureSession() async {
guard await isAuthorized else { return }
// Set up the capture session.
}
}


struct accessCameraView: UIViewControllerRepresentable {

@Binding var selectedImage: UIImage?
@Environment(\.presentationMode) var isPresented

func makeUIViewController(context: Context) -> UIImagePickerController {
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .camera
imagePicker.allowsEditing = true
imagePicker.delegate = context.coordinator
return imagePicker
}

func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) {

}

func makeCoordinator() -> Coordinator {
return Coordinator(picker: self)
}
}

// Coordinator will help to preview the selected image in the View.
class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
var picker: accessCameraView

init(picker: accessCameraView) {
self.picker = picker
}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
guard let selectedImage = info[.originalImage] as? UIImage else { return }
self.picker.selectedImage = selectedImage
self.picker.isPresented.wrappedValue.dismiss()
}
}

0 comments on commit 1a5e1b0

Please sign in to comment.