Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Tutorial 5: Show Post on Detail Screen

Tutorial 5: Show Post on Detail Screen

When clicking on an item in the Home App screenWhen tapping on a Post item, it navigates to a detail Detail screen. And , and display data response from Detail Resource API

Detail Resource API pattern: "url/restful_api/mobile/post/post_id?access_token=token" Logic code

Code of the API implements is implemented in method findOne() of PostApi class. ID parameter resolves will be resolved automatically. The resolver Resolver instance is a helper class help to extract Helper class that helps extract or validate parameters from the request.
PostApi.php

Code Block
class PostApi extends AbstractResourceApi implements MobileAppSettingInterface

...


{

...


/.../

...


	public function findOne($params)

...


	{
		$id = $this->resolver->resolveId($params);

...


		// Todo: Loading data form database and build as resource

...


		$post = new PostResource([

...


			'post_id' => $id,

...


			'title' => "Post's title example " . $id,

...


			'description' => "Post's description " . $id,

...


			'text' => "Post's Full Text " .$id

...


		]);

...


		return $this->success($post);

...


	}

...


}


 
The result of the detail screen Detail screens are as following images
Image Modified          Image Modified