You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-20 23:30:05 +02:00
Mobile: Resolves #2595: Add undo/redo support
This commit is contained in:
@@ -61,8 +61,8 @@ class ScreenHeaderComponent extends React.PureComponent {
|
||||
iconButton: {
|
||||
flex: 1,
|
||||
backgroundColor: theme.backgroundColor2,
|
||||
paddingLeft: 15,
|
||||
paddingRight: 15,
|
||||
paddingLeft: 10,
|
||||
paddingRight: 10,
|
||||
paddingTop: PADDING_V,
|
||||
paddingBottom: PADDING_V,
|
||||
},
|
||||
@@ -248,6 +248,36 @@ class ScreenHeaderComponent extends React.PureComponent {
|
||||
);
|
||||
}
|
||||
|
||||
const renderTopButton = (options) => {
|
||||
if (!options.visible) return null;
|
||||
|
||||
const icon = <Icon name={options.iconName} style={this.styles().topIcon} />;
|
||||
const viewStyle = options.disabled ? this.styles().iconButtonDisabled : this.styles().iconButton;
|
||||
|
||||
return (
|
||||
<TouchableOpacity onPress={options.onPress} style={{ padding: 0 }} disabled={!!options.disabled}>
|
||||
<View style={viewStyle}>{icon}</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
|
||||
const renderUndoButton = () => {
|
||||
return renderTopButton({
|
||||
iconName: 'md-undo',
|
||||
onPress: this.props.onUndoButtonPress,
|
||||
visible: this.props.showUndoButton,
|
||||
disabled: this.props.undoButtonDisabled,
|
||||
});
|
||||
};
|
||||
|
||||
const renderRedoButton = () => {
|
||||
return renderTopButton({
|
||||
iconName: 'md-redo',
|
||||
onPress: this.props.onRedoButtonPress,
|
||||
visible: this.props.showRedoButton,
|
||||
});
|
||||
};
|
||||
|
||||
function selectAllButton(styles, onPress) {
|
||||
return (
|
||||
<TouchableOpacity onPress={onPress}>
|
||||
@@ -462,6 +492,8 @@ class ScreenHeaderComponent extends React.PureComponent {
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||
{sideMenuComp}
|
||||
{backButtonComp}
|
||||
{renderUndoButton(this.styles())}
|
||||
{renderRedoButton(this.styles())}
|
||||
{saveButton(
|
||||
this.styles(),
|
||||
() => {
|
||||
|
||||
Reference in New Issue
Block a user