Fix Option modal items tap effect off center (#2109)

* Fix Option modal items tap effect off center

* Add snapshot
This commit is contained in:
Elias Nahum 2018-09-13 09:57:54 -03:00 committed by GitHub
parent f71ea2814b
commit a873640e41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 2844 additions and 14 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,43 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {shallow} from 'enzyme';
import OptionModalListIOS from './options_modal_list.ios';
import OptionModalListAndroid from './options_modal_list.android';
describe('OptionModalList', () => {
const baseProps = {
items: [{
action: jest.fn(),
text: {
id: 'mobile.file_upload.camera',
defaultMessage: 'Take Photo or Video',
},
icon: 'camera',
}, {
action: jest.fn(),
text: {
id: 'mobile.file_upload.library',
defaultMessage: 'Photo Library',
},
icon: 'photo',
}],
onCancelPress: jest.fn(),
title: 'test',
};
test('should match snapshot for iOS', async () => {
const wrapper = shallow(
<OptionModalListIOS {...baseProps}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot for Android', async () => {
const wrapper = shallow(
<OptionModalListAndroid {...baseProps}/>,
);
expect(wrapper).toMatchSnapshot();
});
});

View file

@ -43,20 +43,24 @@ export default class OptionsModalList extends PureComponent {
}
return (
<TouchableOpacity
<View
key={index}
onPress={preventDoubleTap(item.action)}
style={[style.option, style.optionBorder]}
style={style.optionBorder}
>
{textComponent}
{item.icon &&
<TouchableOpacity
onPress={preventDoubleTap(item.action)}
style={style.option}
>
{textComponent}
{item.icon &&
<IconFont
name={item.icon}
size={18}
style={style.optionIcon}
/>
}
</TouchableOpacity>
}
</TouchableOpacity>
</View>
);
});

View file

@ -47,20 +47,24 @@ export default class OptionsModalList extends PureComponent {
}
return (
<TouchableOpacity
<View
key={index}
onPress={preventDoubleTap(item.action)}
style={[style.option, (index < items.length - 1 && style.optionBorder)]}
style={(index < items.length - 1 && style.optionBorder)}
>
{textComponent}
{item.icon &&
<TouchableOpacity
onPress={preventDoubleTap(item.action)}
style={style.option}
>
{textComponent}
{item.icon &&
<IconFont
name={item.icon}
size={18}
style={style.optionIcon}
/>
}
</TouchableOpacity>
}
</TouchableOpacity>
</View>
);
});