Uncomment rotation code

This commit is contained in:
renahlee
2023-05-07 22:41:55 -07:00
parent 65def7113f
commit 6269f3b928
2 changed files with 24 additions and 27 deletions
-1
View File
@@ -182,7 +182,6 @@ export class ImageModel implements RNImage {
modifiers.push({flip: FlipType.Vertical}) modifiers.push({flip: FlipType.Vertical})
} }
// TODO: Fix rotation -- currently not functional
if (rotate !== undefined) { if (rotate !== undefined) {
this.rotation = rotate this.rotation = rotate
} }
+24 -26
View File
@@ -43,8 +43,7 @@ export const Component = observer(function ({image, gallery}: Props) {
image.flipVertical ?? false, image.flipVertical ?? false,
) )
// TODO: doesn't seem to be working correctly with crop const [rotation, setRotation] = useState(image.rotation ?? 0)
// const [rotation, setRotation] = useState(image.rotation ?? 0)
const [scale, setScale] = useState<number>(image.scale ?? 1) const [scale, setScale] = useState<number>(image.scale ?? 1)
const [position, setPosition] = useState<Position>() const [position, setPosition] = useState<Position>()
const [isEditing, setIsEditing] = useState(false) const [isEditing, setIsEditing] = useState(false)
@@ -54,12 +53,11 @@ export const Component = observer(function ({image, gallery}: Props) {
() => ({ () => ({
...(scale !== 1 ? {scale} : {}), ...(scale !== 1 ? {scale} : {}),
...(position !== undefined ? {position} : {}), ...(position !== undefined ? {position} : {}),
// TODO: doesn't seem to be working correctly with crop ...(rotation !== undefined ? {rotate: rotation} : {}),
// ...(rotation !== undefined ? {rotate: rotation} : {}),
...(flipHorizontal !== undefined ? {flipHorizontal} : {}), ...(flipHorizontal !== undefined ? {flipHorizontal} : {}),
...(flipVertical !== undefined ? {flipVertical} : {}), ...(flipVertical !== undefined ? {flipVertical} : {}),
}), }),
[flipHorizontal, flipVertical, position, scale], [flipHorizontal, flipVertical, rotation, position, scale],
) )
useEffect(() => { useEffect(() => {
@@ -110,26 +108,26 @@ export const Component = observer(function ({image, gallery}: Props) {
const adjustments = useMemo( const adjustments = useMemo(
() => () =>
[ [
// { {
// name: 'rotate-left', name: 'rotate-left',
// label: 'Rotate left', label: 'Rotate left',
// hint: 'Rotate image left', hint: 'Rotate image left',
// onPress: () => { onPress: () => {
// const rotate = (rotation - 90) % 360 const rotate = (rotation - 90) % 360
// setRotation(rotate) setRotation(rotate)
// image.manipulate({rotate}) image.manipulate({rotate})
// }, },
// }, },
// { {
// name: 'rotate-right', name: 'rotate-right',
// label: 'Rotate right', label: 'Rotate right',
// hint: 'Rotate image right', hint: 'Rotate image right',
// onPress: () => { onPress: () => {
// const rotate = (rotation + 90) % 360 const rotate = (rotation + 90) % 360
// setRotation(rotate) setRotation(rotate)
// image.manipulate({rotate}) image.manipulate({rotate})
// }, },
// }, },
{ {
name: 'flip', name: 'flip',
label: 'Flip horizontal', label: 'Flip horizontal',
@@ -143,7 +141,7 @@ export const Component = observer(function ({image, gallery}: Props) {
onPress: onFlipVertical, onPress: onFlipVertical,
}, },
] as const, ] as const,
[onFlipHorizontal, onFlipVertical], [image, rotation, onFlipHorizontal, onFlipVertical],
) )
useEffect(() => { useEffect(() => {