thomas-coldwell / expo-image-editor

A super simple image cropping and rotation tool for Expo that runs on iOS, Android and Web!
163 stars 31 forks source link

Custom UI component #17

Open giautm opened 3 years ago

giautm commented 3 years ago

Hi, Thank you for build great library :+1:

I also want to replace expo-image-editor component's with others from my UI kit: Icon/Text, or BackIcon/BackTitle. For example:

      <ImageEditor
        visible={editorVisible}
        ControlComponent={MyControlComponentFromUIKit} // <----- allow custom
        onCloseEditor={() => setEditorVisible(false)}
        imageUri={imageUri}
        fixedCropAspectRatio={16 / 9}
        lockAspectRatio={aspectLock}
        minimumCropDimensions={{
          width: 100,
          height: 100,
        }}
        onEditingComplete={(result) => {
          setImageData(result);
        }}
      />

It also allow me to disable any function that I don't need, for example: adjust with blue effect.

thomas-coldwell commented 3 years ago

Thanks dude! 😁 I think the best option here would be to introduce 2 different customisation options:

It would probably look something like:

<ImageEditor
    visible={editorVisible}
    iconCustomisation={{back: {text: 'Retour', icon: <MyCustomIcon />}}}  // <-- Icon customisation / localisation
    allowedOperations={["blur", "crop"]} // <-- Specify what operations should be allowed
    onCloseEditor={() => setEditorVisible(false)}
    imageUri={imageUri}
    fixedCropAspectRatio={16 / 9}
    lockAspectRatio={aspectLock}
    minimumCropDimensions={{
        width: 100,
        height: 100,
     }}
     onEditingComplete={(result) => {
        setImageData(result);
     }}
    />

I think that level of customisation should be sufficient for most use cases without having to replace the whole control bar component entirely. Let me know what you think and feel free to open a PR to add these options in!