Skip to content

Commit

Permalink
Merge pull request #1 from KhubaibKhan4/clean
Browse files Browse the repository at this point in the history
-Features Cleanup Impl
  • Loading branch information
KhubaibKhan4 authored Jan 25, 2025
2 parents 2167e0c + d3aa428 commit 46dd5eb
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 10 deletions.
Binary file added .DS_Store
Binary file not shown.
12 changes: 10 additions & 2 deletions Notes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
/* Begin PBXFileSystemSynchronizedRootGroup section */
49B7C3BC2D00D8E900FE8DE5 /* Resources */ = {
isa = PBXFileSystemSynchronizedRootGroup;
exceptions = (
);
path = Resources;
sourceTree = "<group>";
};
Expand All @@ -47,12 +49,20 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
3622B93368E04F3CCE63554D /* Pods */ = {
isa = PBXGroup;
children = (
);
path = Pods;
sourceTree = "<group>";
};
49BA1F7D2CBD8E700099CDCB = {
isa = PBXGroup;
children = (
49B7C3BC2D00D8E900FE8DE5 /* Resources */,
49BA1F882CBD8E700099CDCB /* Notes */,
49BA1F872CBD8E700099CDCB /* Products */,
3622B93368E04F3CCE63554D /* Pods */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -84,8 +94,6 @@
49BA1F882CBD8E700099CDCB /* Notes */,
);
name = Notes;
packageProductDependencies = (
);
productName = Notes;
productReference = 49BA1F862CBD8E700099CDCB /* Notes.app */;
productType = "com.apple.product-type.application";
Expand Down
Binary file not shown.
10 changes: 10 additions & 0 deletions Notes.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Notes/AddNotes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct AddNotes: View {
)
}

Section("Photos") {
Section("Media") {
Button("Add Media", systemImage: "photo.on.rectangle.angled.fill") {
locationManager.checkLocationAuthorization()
}
Expand Down
4 changes: 0 additions & 4 deletions Notes/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ struct ContentView: View {
@State private var isSelected : Int = 0
@AppStorage("isPermissionGranted") var isPermissionGranted = false
var body: some View {
if !isPermissionGranted {
PermissionScreen()
}else {
TabView(selection:$isSelected) {
Tab("Home", systemImage: "house",value: 0) {
HomeScreen()
Expand All @@ -31,7 +28,6 @@ struct ContentView: View {
}

}
}
}
}

Expand Down
56 changes: 53 additions & 3 deletions Notes/permissions_handler/PermissionScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ struct PermissionScreen: View {
@State var locationPermissionText: String = "Allow Location"

@AppStorage("isPermissionGranted") private var isPermissionGranted = false
@State var isCroppingEnabled: Bool = false

@State var capturedImage: UIImage? = nil

var body: some View {
VStack(alignment: .center, spacing: CGFloat(6)) {
Expand All @@ -32,9 +35,13 @@ struct PermissionScreen: View {

Button {
requestCameraPermission()
if cameraPermission == .authorized {
if cameraPermission == .authorized {
//isPermissionGranted = true
cameraPermissionText = "Camera Permission Granted"

ImagePicker(sourceType: .camera, completion: { image in
capturedImage = image
}, isCropping: $isCroppingEnabled)

} else {
cameraPermissionText = "Allow Camera"
}
Expand All @@ -53,7 +60,8 @@ struct PermissionScreen: View {
} label: {
Label("Allow Location", systemImage: "location")
}
}.onAppear {
}
.onAppear {
cameraPermission = AVCaptureDevice.authorizationStatus(for: .video)
}
}
Expand All @@ -65,4 +73,46 @@ struct PermissionScreen: View {
}
}
}

}

struct ImagePicker: UIViewControllerRepresentable {
var sourceType: UIImagePickerController.SourceType
var completion: (UIImage) -> Void
@Binding var isCropping: Bool

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)
}

class Coordinator: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
let parent: ImagePicker

init(_ parent: ImagePicker) {
self.parent = parent
}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
if let image = info[.originalImage] as? UIImage {
parent.completion(image)
parent.isCropping = true
}
picker.dismiss(animated: true)
}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true)
}
}
}


0 comments on commit 46dd5eb

Please sign in to comment.