tns-template-master-detail-kinvey
Version:
Master-detail interface to display collection of items from Kinvey and inspect and edit selected item properties.
58 lines (48 loc) • 2.35 kB
JavaScript
const { Frame } = require("tns-core-modules/ui/frame");
const CarDetailViewModel = require("./car-detail-view-model");
/* ***********************************************************
* This is the item details code behind in the master-detail structure.
* This code behind retrieves the passed parameter from the master list component,
* finds the data item by this parameter and displays the detailed data item information.
*************************************************************/
/* ***********************************************************
* Use the "onNavigatingTo" handler to initialize the page binding context.
*************************************************************/
function onNavigatingTo(args) {
/* ***********************************************************
* The "onNavigatingTo" event handler lets you detect if the user navigated with a back button.
* Skipping the re-initialization on back navigation means the user will see the
* page in the same data state that he left it in before navigating.
*************************************************************/
if (args.isBackNavigation) {
return;
}
const page = args.object;
page.bindingContext = new CarDetailViewModel(page.navigationContext);
}
/* ***********************************************************
* The back button is essential for a master-detail feature.
*************************************************************/
function onBackButtonTap() {
Frame.topmost().goBack();
}
/* ***********************************************************
* The master-detail template comes with an example of an item edit page.
* Check out the edit page in the /cars/car-detail-edit-page folder.
*************************************************************/
function onEditButtonTap(args) {
const bindingContext = args.object.bindingContext;
Frame.topmost().navigate({
moduleName: "cars/car-detail-edit-page/car-detail-edit-page",
context: bindingContext.car,
animated: true,
transition: {
name: "slideTop",
duration: 200,
curve: "ease"
}
});
}
exports.onNavigatingTo = onNavigatingTo;
exports.onBackButtonTap = onBackButtonTap;
exports.onEditButtonTap = onEditButtonTap;