Changed boolean to event, to execute in Mendix
This commit is contained in:
24
README.md
24
README.md
@@ -1,25 +1,17 @@
|
|||||||
## Backhandler
|
## Backhandler
|
||||||
Widget to disregard back events on page when using Mendix Native.
|
[Disregard back events on page]
|
||||||
|
|
||||||
|
## Features
|
||||||
|
[feature highlights]
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
For development:
|
[step by step instructions]
|
||||||
|
|
||||||
Create customwidgets folder in root of project directory
|
|
||||||
Git clone this repo into customwidgets folder
|
|
||||||
Open command prompt in cloned folder
|
|
||||||
npm i
|
|
||||||
npm run dev / npm run build
|
|
||||||
Widget can now be used inside Mendix.
|
|
||||||
|
|
||||||
For plain usage:
|
|
||||||
|
|
||||||
Copy MPK file in releases to widgets directory.
|
|
||||||
|
|
||||||
## Demo project
|
## Demo project
|
||||||
Not available yet.
|
[link to sandbox]
|
||||||
|
|
||||||
## Issues, suggestions and feature requests
|
## Issues, suggestions and feature requests
|
||||||
https://github.com/IncentroBA/backhandler/issues
|
[link to GitHub issues]
|
||||||
|
|
||||||
## Development and contribution
|
## Development and contribution
|
||||||
N/A
|
[specify contribute]
|
||||||
|
|||||||
BIN
dist/1.0.0/incentro.Backhandler.mpk
vendored
BIN
dist/1.0.0/incentro.Backhandler.mpk
vendored
Binary file not shown.
13
dist/tmp/widgets/Backhandler.xml
vendored
13
dist/tmp/widgets/Backhandler.xml
vendored
@@ -7,14 +7,11 @@
|
|||||||
<description>Disregard back events on page</description>
|
<description>Disregard back events on page</description>
|
||||||
<icon/>
|
<icon/>
|
||||||
<properties>
|
<properties>
|
||||||
<propertyGroup caption="General">
|
<propertyGroup caption="Events">
|
||||||
<property key="disableBack" type="attribute" required="true">
|
<property key="onBack" type="action" required="false">
|
||||||
<caption>Disable</caption>
|
<caption>On backpress</caption>
|
||||||
<description>Boolean for enabling/disabling backhandler</description>
|
<description>Flow to call when hardware backbutton is used.</description>
|
||||||
<attributeTypes>
|
|
||||||
<attributeType name="Boolean"/>
|
|
||||||
</attributeTypes>
|
|
||||||
</property>
|
</property>
|
||||||
</propertyGroup>
|
</propertyGroup>
|
||||||
</properties>
|
</properties>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -112,14 +112,14 @@ class Backhandler extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|||||||
return (Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["View"], null));
|
return (Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["View"], null));
|
||||||
}
|
}
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
if (this.props.disableBack) {
|
react_native__WEBPACK_IMPORTED_MODULE_1__["BackHandler"].addEventListener('hardwareBackPress', this.handleBackButtonClick);
|
||||||
react_native__WEBPACK_IMPORTED_MODULE_1__["BackHandler"].addEventListener('hardwareBackPress', this.handleBackButtonClick);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
react_native__WEBPACK_IMPORTED_MODULE_1__["BackHandler"].removeEventListener('hardwareBackPress', this.handleBackButtonClick);
|
react_native__WEBPACK_IMPORTED_MODULE_1__["BackHandler"].removeEventListener('hardwareBackPress', this.handleBackButtonClick);
|
||||||
}
|
}
|
||||||
handleBackButtonClick() {
|
handleBackButtonClick() {
|
||||||
|
var _a;
|
||||||
|
(_a = this.props.onBack) === null || _a === void 0 ? void 0 : _a.execute();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -16,6 +16,7 @@ export class Backhandler extends Component<BackhandlerProps<CustomStyle>> {
|
|||||||
this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
|
this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//We have to have a render block, or else Mendix Native will crash. Render block is expected.
|
||||||
render(): ReactNode {
|
render(): ReactNode {
|
||||||
return (
|
return (
|
||||||
<View></View>
|
<View></View>
|
||||||
@@ -23,9 +24,7 @@ export class Backhandler extends Component<BackhandlerProps<CustomStyle>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
if (this.props.disableBack) {
|
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
|
||||||
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@@ -33,6 +32,7 @@ export class Backhandler extends Component<BackhandlerProps<CustomStyle>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleBackButtonClick() {
|
handleBackButtonClick() {
|
||||||
|
this.props.onBack?.execute();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,11 @@
|
|||||||
<description>Disregard back events on page</description>
|
<description>Disregard back events on page</description>
|
||||||
<icon/>
|
<icon/>
|
||||||
<properties>
|
<properties>
|
||||||
<propertyGroup caption="General">
|
<propertyGroup caption="Events">
|
||||||
<property key="disableBack" type="attribute" required="true">
|
<property key="onBack" type="action" required="false">
|
||||||
<caption>Disable</caption>
|
<caption>On backpress</caption>
|
||||||
<description>Boolean for enabling/disabling backhandler</description>
|
<description>Flow to call when hardware backbutton is used.</description>
|
||||||
<attributeTypes>
|
|
||||||
<attributeType name="Boolean"/>
|
|
||||||
</attributeTypes>
|
|
||||||
</property>
|
</property>
|
||||||
</propertyGroup>
|
</propertyGroup>
|
||||||
</properties>
|
</properties>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
6
typings/BackhandlerProps.d.ts
vendored
6
typings/BackhandlerProps.d.ts
vendored
@@ -3,16 +3,16 @@
|
|||||||
* WARNING: All changes made to this file will be overwritten
|
* WARNING: All changes made to this file will be overwritten
|
||||||
* @author Mendix UI Content Team
|
* @author Mendix UI Content Team
|
||||||
*/
|
*/
|
||||||
import { EditableValue } from "mendix";
|
import { ActionValue } from "mendix";
|
||||||
|
|
||||||
export interface BackhandlerProps<Style> {
|
export interface BackhandlerProps<Style> {
|
||||||
name: string;
|
name: string;
|
||||||
style: Style[];
|
style: Style[];
|
||||||
disableBack: EditableValue<boolean>;
|
onBack?: ActionValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BackhandlerPreviewProps {
|
export interface BackhandlerPreviewProps {
|
||||||
class: string;
|
class: string;
|
||||||
style: string;
|
style: string;
|
||||||
disableBack: string;
|
onBack: {} | null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user