Skip to content

Commit

Permalink
fix(floating-action-button-native): fix center icons
Browse files Browse the repository at this point in the history
  • Loading branch information
UrazAkgultan committed Mar 18, 2024
1 parent ccdff01 commit c4ead01
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Fixed

- We have fixed an issue where icons within Floating Action Buttons were not properly centered.

## [4.0.1] - 2023-10-24

### Fixed

- We have fixed an error related to useNativeDriver.
- We have fixed an error related to useNativeDriver.

## [4.0.0] - 2023-3-28

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "floating-action-button-native",
"widgetName": "FloatingActionButton",
"version": "4.0.1",
"version": "4.0.2",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ export class FloatingActionButton extends Component<FloatingActionButtonProps<Fl
const isActive = this.state.active && this.props.secondaryButtons.length > 0;
const source = isActive ? activeIconSource : iconSource;
const style = isActive ? { transform: [{ rotate: "-180deg" }] } : {};
const buttonContainerStyle = [this.styles.button, this.styles.buttonContainer];

return (
<View testID={"FloatingAction$IconView"} style={[style, this.styles.buttonIconContainer]}>
<Icon icon={source} size={this.styles.buttonIcon.size} color={this.styles.buttonIcon.color} />
<View testID={"FloatingAction$IconView"} style={buttonContainerStyle}>
<View style={[style, this.styles.buttonIconContainer]}>
<Icon icon={source} size={this.styles.buttonIcon.size} color={this.styles.buttonIcon.color} />
</View>
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FloatingActionButton } from "../FloatingActionButton";
import { actionValue, dynamicValue } from "@mendix/piw-utils-internal";
import { NativeIcon } from "mendix";
import { Icon } from "mendix/components/native/Icon";
import { ReactTestInstance } from "react-test-renderer";

describe("FloatingActionButton", () => {
let defaultProps: FloatingActionButtonProps<FloatingActionButtonStyle>;
Expand Down Expand Up @@ -116,7 +117,7 @@ describe("FloatingActionButton", () => {
);
const transformStyle = [{ transform: [{ rotate: "-180deg" }] }];

const iconView = getByTestId("FloatingAction$IconView");
const iconView = getByTestId("FloatingAction$IconView").children[0] as ReactTestInstance;
const iconComponent = iconView.findByType(Icon);
expect(iconComponent.props.icon).toEqual(icon.value);
expect(iconView.props.style).not.toEqual(expect.arrayContaining(transformStyle));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,46 @@ exports[`FloatingActionButton renders correct props with secondary buttons 1`] =
<View
style={
[
{},
{
"backgroundColor": "#e74c3c",
"elevation": 5,
"rippleColor": "rgba(0, 0, 0, 0.4)",
"shadowColor": "#000",
"shadowOffset": {
"height": 5,
"width": 0,
},
"shadowOpacity": 0.3,
"shadowRadius": 3,
"size": 54,
},
{
"alignItems": "center",
"flexShrink": 1,
"borderRadius": 27,
"height": 54,
"justifyContent": "center",
"width": 54,
},
]
}
testID="FloatingAction$IconView"
>
<View
testId="icon"
/>
style={
[
{},
{
"alignItems": "center",
"flexShrink": 1,
"justifyContent": "center",
},
]
}
>
<View
testId="icon"
/>
</View>
</View>
</View>
</View>
Expand Down Expand Up @@ -369,19 +396,46 @@ exports[`FloatingActionButton renders correct props without secondary buttons 1`
<View
style={
[
{},
{
"backgroundColor": "#e74c3c",
"elevation": 5,
"rippleColor": "rgba(0, 0, 0, 0.4)",
"shadowColor": "#000",
"shadowOffset": {
"height": 5,
"width": 0,
},
"shadowOpacity": 0.3,
"shadowRadius": 3,
"size": 54,
},
{
"alignItems": "center",
"flexShrink": 1,
"borderRadius": 27,
"height": 54,
"justifyContent": "center",
"width": 54,
},
]
}
testID="FloatingAction$IconView"
>
<View
testId="icon"
/>
style={
[
{},
{
"alignItems": "center",
"flexShrink": 1,
"justifyContent": "center",
},
]
}
>
<View
testId="icon"
/>
</View>
</View>
</View>
</View>
Expand Down Expand Up @@ -564,19 +618,46 @@ exports[`FloatingActionButton vertical position renders position bottom correctl
<View
style={
[
{},
{
"backgroundColor": "#e74c3c",
"elevation": 5,
"rippleColor": "rgba(0, 0, 0, 0.4)",
"shadowColor": "#000",
"shadowOffset": {
"height": 5,
"width": 0,
},
"shadowOpacity": 0.3,
"shadowRadius": 3,
"size": 54,
},
{
"alignItems": "center",
"flexShrink": 1,
"borderRadius": 27,
"height": 54,
"justifyContent": "center",
"width": 54,
},
]
}
testID="FloatingAction$IconView"
>
<View
testId="icon"
/>
style={
[
{},
{
"alignItems": "center",
"flexShrink": 1,
"justifyContent": "center",
},
]
}
>
<View
testId="icon"
/>
</View>
</View>
</View>
</View>
Expand Down Expand Up @@ -759,19 +840,46 @@ exports[`FloatingActionButton vertical position renders position top correctly 1
<View
style={
[
{},
{
"backgroundColor": "#e74c3c",
"elevation": 5,
"rippleColor": "rgba(0, 0, 0, 0.4)",
"shadowColor": "#000",
"shadowOffset": {
"height": 5,
"width": 0,
},
"shadowOpacity": 0.3,
"shadowRadius": 3,
"size": 54,
},
{
"alignItems": "center",
"flexShrink": 1,
"borderRadius": 27,
"height": 54,
"justifyContent": "center",
"width": 54,
},
]
}
testID="FloatingAction$IconView"
>
<View
testId="icon"
/>
style={
[
{},
{
"alignItems": "center",
"flexShrink": 1,
"justifyContent": "center",
},
]
}
>
<View
testId="icon"
/>
</View>
</View>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="FloatingActionButton" version="4.0.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="FloatingActionButton" version="4.0.2" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="FloatingActionButton.xml" />
</widgetFiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TextStyle, ViewStyle } from "react-native";
export interface FloatingActionButtonStyle extends Style {
container: ViewStyle;
button: PrimaryButtonStyle;
buttonContainer: PrimaryButtonStyle;
buttonIconContainer: ViewStyle;
buttonIcon: IconStyle;
secondaryButton: ButtonStyle;
Expand Down Expand Up @@ -42,6 +43,13 @@ export const defaultFloatingActionButtonStyle: FloatingActionButtonStyle = {
shadowRadius: 3,
elevation: 5
},
buttonContainer: {
width: 54,
height: 54,
justifyContent: "center",
alignItems: "center",
borderRadius: 27
},
buttonIconContainer: {
justifyContent: "center",
alignItems: "center",
Expand Down

0 comments on commit c4ead01

Please sign in to comment.