Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to modify default camera view #33

Closed
belyakov-am opened this issue Jul 15, 2024 · 19 comments
Closed

Add an option to modify default camera view #33

belyakov-am opened this issue Jul 15, 2024 · 19 comments
Assignees

Comments

@belyakov-am
Copy link

belyakov-am commented Jul 15, 2024

It would be nice to be able to hide some buttons from the default camera view

Specifically an option to hide photo / video output buttons

@FulcrumOne
Copy link
Contributor

Hey @belyakov-am,

Your request was added to our roadmap

Thanks for this comment and have a nice day!

@belyakov-am
Copy link
Author

Hey @FulcrumOne

Amazing, thanks. Have a nice day too!

@davit-b
Copy link

davit-b commented Jul 19, 2024

+1 on this. Just hiding some of the fields in the Camera View would be great. I want to disable taking photos, and disable allowing rotating the camera to the front.

@davit-b
Copy link

davit-b commented Jul 19, 2024

Is there a workaround in the meantime? I tried to build a Custom CameraView that looks identical to the DefaultCameraView expect with a few customizations, but many of the dependent structs are marked fileinternal and the bridging is becoming a giant mess.

I don't want to resort to cloning the library and import it as a local dependency just yet.

@FulcrumOne
Copy link
Contributor

hey @davit-b,

Unfortunately there is not; to be honest, I didn't think anyone would want to use the default UI, so I put all the "resources" into making it possible to create your own views.
Nevertheless, I'll try to find the time early next week and implement it by Wednesday if it works for you.

Best regards,
Tomasz

@davit-b
Copy link

davit-b commented Jul 19, 2024

@FulcrumOne

Oh, if you could that we be amazing. The default UI is really great! So naturally I just want to modify it, that would save me a lot of time.

@splons
Copy link

splons commented Jul 21, 2024

Another vote for this one, thank you for considering it.

I have an application where I just want to take photos (no videos), so this would support that nicely.

@FulcrumOne
Copy link
Contributor

Hey guys,

FYI, I'm having some delays at work, so unfortunately I have to postpone the start of the work to Friday.
Apologies for this, I will keep you in the loop.

Best regards,
Tomasz

@davit-b
Copy link

davit-b commented Jul 25, 2024

Ok, thank you for the update.

@FulcrumOne
Copy link
Contributor

I'm starting my work and will try to deliver something today.

@FulcrumOne FulcrumOne self-assigned this Jul 26, 2024
@FulcrumOne
Copy link
Contributor

FulcrumOne commented Jul 27, 2024

@davit-b, @splons, @belyakov-am

The feature was implemented in branch named patch-2.1.0. Could you check it out and let me know if it works as expected?

Here is an example of how to use it:

MCameraController(manager: manager)
    .cameraScreen {
        DefaultCameraView(cameraManager: $0, namespace: $1, closeControllerAction: $2)
            .torchButtonVisible(false)
            .outputTypePickerVisible(false)
            .flipButtonVisible(false)
    }

@davit-b
Copy link

davit-b commented Jul 27, 2024

@FulcrumOne

Just implemented, it meets all my needs. Thank you so much!!

@FulcrumOne FulcrumOne mentioned this issue Jul 27, 2024
FulcrumOne added a commit that referenced this issue Jul 28, 2024
feat:
- Added possibility to customise DefaultCameraView (#33)
- Added option to change camera frame rate (#28)
- Extended ability to customise behaviour after media capture (#34)
- Added ability to change camera resolution

fix:
- Fixed problem with package manager (#29)
@FulcrumOne
Copy link
Contributor

Thank you too! I'm closing the issue then.

@splons
Copy link

splons commented Jul 30, 2024

Thank you for the fast work on this request!

The outputTypePickerVisible modifier does exactly what I need -- perfect.

I tested the other modifiers from your sample code above and found that adding .flipButtonVisible(false) does not hide the button to flip from back to front cameras (assuming that is what is intended).

@FulcrumOne
Copy link
Contributor

Hey @splons,

The Flip button is located on the navigation bar - it essentially flips the view from camera horizontally.
The button you mentioned is hidden with the cameraPositionButtonVisible function.

Have a nice day,
T.K.

@tiendq
Copy link

tiendq commented Dec 16, 2024

@davit-b, @splons, @belyakov-am

The feature was implemented in branch named patch-2.1.0. Could you check it out and let me know if it works as expected?

Here is an example of how to use it:

MCameraController(manager: manager)
    .cameraScreen {
        DefaultCameraView(cameraManager: $0, namespace: $1, closeControllerAction: $2)
            .torchButtonVisible(false)
            .outputTypePickerVisible(false)
            .flipButtonVisible(false)
    }

Hi, could you give me an example for newly changes MCameraScreen? I don't know how to make it work to get same result as I could with previous sample app as below. It's just turning on/off a few options so I think I don't need to define a new custom struct.

MCameraController(manager: manager)
        .cameraScreen {
          // Change default camera view (with on/off options)
          DefaultCameraView(cameraManager: $0, namespace: $1, closeControllerAction: $2)
            .cameraPositionButtonVisible(false)
            .flipButtonVisible(false)
            .outputTypePickerVisible(false)
        }

@FulcrumOne
Copy link
Contributor

@tiendq, you can see the methods available in the Public+UI+DefaultCameraScreen file; in a nutshell they have been renamed from (...)Visible to (...)Allowed

@tiendq
Copy link

tiendq commented Dec 17, 2024

@tiendq, you can see the methods available in the Public+UI+DefaultCameraScreen file; in a nutshell they have been renamed from (...)Visible to (...)Allowed

Thank you, it works now.

BTW, I believe there is a very minor issue in this line, it should be CustomCameraScreen (and not CustomCameraErrorScreen).

@ronaldho
Copy link

I'm a bit confused on how to set this up after 3.0 patch launched. In my content view, this is what I've tried doing but it doesn't seem to be right.

struct ContentView: View {
//    @State private var isSheetPresented: Bool = false
    @ObservedObject var cameraManager: CameraManager
    let namespace: Namespace.ID
    let closeMCameraAction: () -> ()
    var body: some View {
    MCamera()
            .setCameraScreen(DefaultCameraScreen(cameraManager: cameraManager, namespace: namespace, closeMCameraAction: <#T##() -> Void#>))
                
            
            // MUST BE CALLED!
            .startSession()
        
    }
}

Thanks in advance for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants