Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
feelver
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2F-ART
feelver
Commits
02b8f551
Commit
02b8f551
authored
Jul 20, 2020
by
Mobile : Ball (Apprentice)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
5c548d8a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
260 additions
and
41 deletions
+260
-41
lib/main.dart
+1
-0
lib/model/category/category_model.dart
+97
-0
lib/model/home/home_model.dart
+73
-0
lib/service/api.dart
+36
-28
lib/ui/home/home.dart
+7
-1
lib/ui/home/home_presenter.dart
+34
-0
pubspec.lock
+12
-12
No files found.
lib/main.dart
View file @
02b8f551
import
'package:feelverapp/ui/booking/booking_detail.dart'
;
import
'package:feelverapp/ui/booking/booking_detail.dart'
;
import
'package:feelverapp/ui/home/home.dart'
;
import
'package:feelverapp/ui/login/login.dart'
;
import
'package:feelverapp/ui/login/login.dart'
;
import
'package:feelverapp/ui/my_reviews/my_reviews_page.dart'
;
import
'package:feelverapp/ui/my_reviews/my_reviews_page.dart'
;
import
'package:feelverapp/ui/shop/shop_main.dart'
;
import
'package:feelverapp/ui/shop/shop_main.dart'
;
...
...
lib/model/category/category_model.dart
View file @
02b8f551
class
categoryModel
{
List
<
DATA
>
dATA
;
categoryModel
({
this
.
dATA
});
categoryModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
if
(
json
[
'DATA'
]
!=
null
)
{
dATA
=
new
List
<
DATA
>();
json
[
'DATA'
].
forEach
((
v
)
{
dATA
.
add
(
new
DATA
.
fromJson
(
v
));
});
}
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
if
(
this
.
dATA
!=
null
)
{
data
[
'DATA'
]
=
this
.
dATA
.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
return
data
;
}
}
class
DATA
{
int
id
;
int
parentId
;
String
name
;
String
code
;
String
displayName
;
String
cover
;
String
detail
;
Null
type
;
String
status
;
int
sortOrder
;
Null
storeId
;
Null
vendorId
;
Null
createdAt
;
String
updatedAt
;
String
visibility
;
DATA
(
{
this
.
id
,
this
.
parentId
,
this
.
name
,
this
.
code
,
this
.
displayName
,
this
.
cover
,
this
.
detail
,
this
.
type
,
this
.
status
,
this
.
sortOrder
,
this
.
storeId
,
this
.
vendorId
,
this
.
createdAt
,
this
.
updatedAt
,
this
.
visibility
});
DATA
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
parentId
=
json
[
'parent_id'
];
name
=
json
[
'name'
];
code
=
json
[
'code'
];
displayName
=
json
[
'display_name'
];
cover
=
json
[
'cover'
];
detail
=
json
[
'detail'
];
type
=
json
[
'type'
];
status
=
json
[
'status'
];
sortOrder
=
json
[
'sort_order'
];
storeId
=
json
[
'store_id'
];
vendorId
=
json
[
'vendor_id'
];
createdAt
=
json
[
'created_at'
];
updatedAt
=
json
[
'updated_at'
];
visibility
=
json
[
'visibility'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'parent_id'
]
=
this
.
parentId
;
data
[
'name'
]
=
this
.
name
;
data
[
'code'
]
=
this
.
code
;
data
[
'display_name'
]
=
this
.
displayName
;
data
[
'cover'
]
=
this
.
cover
;
data
[
'detail'
]
=
this
.
detail
;
data
[
'type'
]
=
this
.
type
;
data
[
'status'
]
=
this
.
status
;
data
[
'sort_order'
]
=
this
.
sortOrder
;
data
[
'store_id'
]
=
this
.
storeId
;
data
[
'vendor_id'
]
=
this
.
vendorId
;
data
[
'created_at'
]
=
this
.
createdAt
;
data
[
'updated_at'
]
=
this
.
updatedAt
;
data
[
'visibility'
]
=
this
.
visibility
;
return
data
;
}
}
\ No newline at end of file
lib/model/home/home_model.dart
View file @
02b8f551
class
HomeModel
{
int
id
;
String
parentId
;
String
name
;
String
code
;
String
displayName
;
String
cover
;
String
detail
;
String
type
;
String
status
;
int
sortOrder
;
String
storeId
;
String
vendorId
;
String
createdAt
;
String
updatedAt
;
String
visibility
;
HomeModel
(
{
this
.
id
,
this
.
parentId
,
this
.
name
,
this
.
code
,
this
.
displayName
,
this
.
cover
,
this
.
detail
,
this
.
type
,
this
.
status
,
this
.
sortOrder
,
this
.
storeId
,
this
.
vendorId
,
this
.
createdAt
,
this
.
updatedAt
,
this
.
visibility
});
HomeModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
parentId
=
json
[
'parent_id'
];
name
=
json
[
'name'
];
code
=
json
[
'code'
];
displayName
=
json
[
'display_name'
];
cover
=
json
[
'cover'
];
detail
=
json
[
'detail'
];
type
=
json
[
'type'
];
status
=
json
[
'status'
];
sortOrder
=
json
[
'sort_order'
];
storeId
=
json
[
'store_id'
];
vendorId
=
json
[
'vendor_id'
];
createdAt
=
json
[
'created_at'
];
updatedAt
=
json
[
'updated_at'
];
visibility
=
json
[
'visibility'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'parent_id'
]
=
this
.
parentId
;
data
[
'name'
]
=
this
.
name
;
data
[
'code'
]
=
this
.
code
;
data
[
'display_name'
]
=
this
.
displayName
;
data
[
'cover'
]
=
this
.
cover
;
data
[
'detail'
]
=
this
.
detail
;
data
[
'type'
]
=
this
.
type
;
data
[
'status'
]
=
this
.
status
;
data
[
'sort_order'
]
=
this
.
sortOrder
;
data
[
'store_id'
]
=
this
.
storeId
;
data
[
'vendor_id'
]
=
this
.
vendorId
;
data
[
'created_at'
]
=
this
.
createdAt
;
data
[
'updated_at'
]
=
this
.
updatedAt
;
data
[
'visibility'
]
=
this
.
visibility
;
return
data
;
}
}
\ No newline at end of file
lib/service/api.dart
View file @
02b8f551
...
@@ -2,35 +2,29 @@ import 'dart:convert';
...
@@ -2,35 +2,29 @@ import 'dart:convert';
import
'package:feelverapp/model/Login/login_model.dart'
;
import
'package:feelverapp/model/Login/login_model.dart'
;
import
'package:feelverapp/model/base/base.dart'
;
import
'package:feelverapp/model/base/base.dart'
;
import
'package:feelverapp/model/home/home_model.dart'
;
import
'package:feelverapp/model/register/register_model.dart'
;
import
'package:feelverapp/model/register/register_model.dart'
;
import
'package:feelverapp/model/category/category_model.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:http/http.dart'
as
http
;
class
Api
<
T
>
{
class
Api
<
T
>{
final
String
_baseApi
=
"https://backend-uat.feelver.com/api"
;
final
String
_baseApi
=
"https://backend-uat.feelver.com/api"
;
final
_headerApi
=
{
final
_headerApi
=
{
"Authorization"
:
"Bearer {{ token }}"
,
"Authorization"
:
"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYmFja2VuZC11YXQuZmVlbHZlci5jb21cL2FwaVwvbG9naW4iLCJpYXQiOjE1OTQ5NzIzMjYsImV4cCI6MTYwMjE3MjMyNiwibmJmIjoxNTk0OTcyMzI2LCJqdGkiOiJsM1BldUJVcTdDNldSbzVGIiwic3ViIjo1LCJwcnYiOiI4N2UwYWYxZWY5ZmQxNTgxMmZkZWM5NzE1M2ExNGUwYjA0NzU0NmFhIn0.fwFqcbzG2T_ZHtIcGF13Ek7nIxxwbnaE9ZXGomo-nzY"
,
};
};
Future
<
Response
<
T
>>
login
(
Object
body
)
async
{
Future
<
Response
<
T
>>
login
(
Object
body
)
async
{
var
_model
;
var
_model
;
var
_fail
;
var
_fail
;
var
result
;
var
result
;
// (body as Map)['lang'] = allTranslations.currentLanguage;
// (body as Map)['lang'] = allTranslations.currentLanguage;
await
_httpConnection
(
await
_httpConnection
(
"
${this._baseApi}
/login"
,
this
.
_headerApi
,
body
)
"
${this._baseApi}
/login"
,
this
.
_headerApi
,
body
)
.
then
((
response
)
{
.
then
((
response
)
{
print
(
"ผลลัพ เท่ากับบบบ "
+
"
${response.body}
"
);
print
(
"ผลลัพ เท่ากับบบบ "
+
"
${response.body}
"
);
if
(
response
.
statusCode
==
200
)
{
if
(
response
.
statusCode
==
200
)
{
_model
=
LoginModel
.
fromJson
(
json
.
decode
(
response
.
body
));
_model
=
LoginModel
.
fromJson
(
json
.
decode
(
response
.
body
));
}
else
{
}
else
{
_fail
=
FailModel
.
fromJson
(
json
.
decode
(
response
.
body
));
_fail
=
FailModel
.
fromJson
(
json
.
decode
(
response
.
body
));
...
@@ -40,18 +34,16 @@ class Api<T>{
...
@@ -40,18 +34,16 @@ class Api<T>{
return
result
;
return
result
;
}
}
Future
<
Response
<
T
>>
register
(
Object
body
)
async
{
Future
<
Response
<
T
>>
register
(
Object
body
)
async
{
var
_model
;
var
_model
;
var
_fail
;
var
_fail
;
var
result
;
var
result
;
// (body as Map)['lang'] = allTranslations.currentLanguage;
// (body as Map)['lang'] = allTranslations.currentLanguage;
await
_httpConnection
(
await
_httpConnection
(
"
${this._baseApi}
/register"
,
this
.
_headerApi
,
body
)
"
${this._baseApi}
/register"
,
this
.
_headerApi
,
body
)
.
then
((
response
)
{
.
then
((
response
)
{
print
(
"ผลลัพ เท่ากับบบบ "
+
"
${response.body}
"
);
print
(
"ผลลัพ เท่ากับบบบ "
+
"
${response.body}
"
);
if
(
response
.
statusCode
==
200
)
{
if
(
response
.
statusCode
==
200
)
{
_model
=
RegisterModel
.
fromJson
(
json
.
decode
(
response
.
body
));
_model
=
RegisterModel
.
fromJson
(
json
.
decode
(
response
.
body
));
}
else
{
}
else
{
_fail
=
FailModel
.
fromJson
(
json
.
decode
(
response
.
body
));
_fail
=
FailModel
.
fromJson
(
json
.
decode
(
response
.
body
));
...
@@ -61,19 +53,37 @@ Future<Response<T>> register(Object body) async {
...
@@ -61,19 +53,37 @@ Future<Response<T>> register(Object body) async {
return
result
;
return
result
;
}
}
Future
<
Response
<
T
>>
category
(
Object
body
)
async
{
var
_model
;
var
_fail
;
var
result
;
await
_httpConnection
(
"
${this._baseApi}
/category"
,
this
.
_headerApi
,
body
)
.
then
((
response
)
{
print
(
"ผลลัพท์ เท่ากับ "
"
${response.body}
"
);
if
(
response
.
statusCode
==
200
){
print
(
'testtt'
);
_model
=
categoryModel
.
fromJson
(
json
.
decode
(
response
.
body
));
}
else
{
_fail
=
FailModel
.
fromJson
(
json
.
decode
(
response
.
body
));
}
result
=
new
Response
<
T
>(
_model
,
_fail
);
});
return
result
;
}
///api environment
///api environment
Future
<
http
.
Response
>
_httpConnection
(
Future
<
http
.
Response
>
_httpConnection
(
String
url
,
Map
<
String
,
String
>
headers
,
Object
body
)
async
{
String
url
,
Map
<
String
,
String
>
headers
,
Object
body
)
async
{
if
(
body
!=
null
)
{
if
(
body
!=
null
)
{
final
response
=
headers
!=
null
final
response
=
headers
!=
null
?
http
.
post
(
Uri
.
encodeFull
(
url
),
headers:
headers
,
body:
body
)
?
http
.
post
(
Uri
.
encodeFull
(
url
),
headers:
headers
,
body:
body
)
:
http
.
post
(
Uri
.
encodeFull
(
url
),
body:
body
);
:
http
.
post
(
Uri
.
encodeFull
(
url
),
body:
body
);
return
response
;
return
response
;
}
else
{
}
else
{
final
response
=
headers
!=
null
final
response
=
headers
!=
null
?
http
.
get
(
Uri
.
encodeFull
(
url
),
headers:
headers
)
?
http
.
get
(
Uri
.
encodeFull
(
url
),
headers:
headers
)
:
http
.
get
(
Uri
.
encodeFull
(
url
));
:
http
.
get
(
Uri
.
encodeFull
(
url
));
...
@@ -81,8 +91,6 @@ Future<Response<T>> register(Object body) async {
...
@@ -81,8 +91,6 @@ Future<Response<T>> register(Object body) async {
}
}
}
}
dynamic
_jsonDecode
(
String
json
)
{
dynamic
_jsonDecode
(
String
json
)
{
var
resJson
=
jsonDecode
(
json
);
var
resJson
=
jsonDecode
(
json
);
return
resJson
;
return
resJson
;
...
@@ -92,6 +100,6 @@ Future<Response<T>> register(Object body) async {
...
@@ -92,6 +100,6 @@ Future<Response<T>> register(Object body) async {
class
Response
<
T
>
{
class
Response
<
T
>
{
T
success
;
T
success
;
FailModel
fail
;
FailModel
fail
;
Response
(
this
.
success
,
this
.
fail
);
Response
(
this
.
success
,
this
.
fail
);
}
}
lib/ui/home/home.dart
View file @
02b8f551
import
'package:feelverapp/ui/home/home_presenter.dart'
;
import
'package:feelverapp/ui/login/login.dart'
;
import
'package:feelverapp/ui/login/login.dart'
;
import
'package:feelverapp/ui/menu/menu.dart'
;
import
'package:feelverapp/ui/menu/menu.dart'
;
import
'package:feelverapp/ui/nearme/near_me_list.dart'
;
import
'package:feelverapp/ui/nearme/near_me_list.dart'
;
...
@@ -16,9 +17,13 @@ class HomePage extends StatefulWidget {
...
@@ -16,9 +17,13 @@ class HomePage extends StatefulWidget {
class
_HomePageState
extends
State
<
HomePage
>
{
class
_HomePageState
extends
State
<
HomePage
>
with
TickerProviderStateMixin
{
HomePresenter
presenter
;
@override
@override
void
initState
()
{
void
initState
()
{
presenter
=
HomePresenter
(
this
);
presenter
.
Listitem
();
...
@@ -27,6 +32,7 @@ class _HomePageState extends State<HomePage> {
...
@@ -27,6 +32,7 @@ class _HomePageState extends State<HomePage> {
@override
@override
void
dispose
()
{
void
dispose
()
{
super
.
dispose
();
super
.
dispose
();
}
}
...
...
lib/ui/home/home_presenter.dart
View file @
02b8f551
import
'package:feelverapp/model/category/category_model.dart'
;
import
'package:feelverapp/model/home/home_model.dart'
;
import
'package:feelverapp/service/api.dart'
;
import
'package:feelverapp/service/base_presenter.dart'
;
import
'package:feelverapp/ui/home/home.dart'
;
import
'package:flutter/material.dart'
;
class
HomePresenter
extends
BasePresenter
<
HomePage
>{
Api
_api
;
final
formkey
=
GlobalKey
<
FormState
>();
HomePresenter
(
State
<
HomePage
>
state
)
:
super
(
state
);
Listitem
()
async
{
_api
=
Api
<
categoryModel
>();
var
res
=
await
_api
.
category
({
"access_type"
:
"portal"
});
if
(
res
.
fail
==
null
)
{
print
(
'res Success'
);
}
else
{
print
(
'res Fail'
);
}
}
}
\ No newline at end of file
pubspec.lock
View file @
02b8f551
...
@@ -7,42 +7,42 @@ packages:
...
@@ -7,42 +7,42 @@ packages:
name: archive
name: archive
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "2.0.1
1
"
version: "2.0.1
3
"
args:
args:
dependency: transitive
dependency: transitive
description:
description:
name: args
name: args
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "1.
5.2
"
version: "1.
6.0
"
async:
async:
dependency: transitive
dependency: transitive
description:
description:
name: async
name: async
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "2.4.
0
"
version: "2.4.
1
"
boolean_selector:
boolean_selector:
dependency: transitive
dependency: transitive
description:
description:
name: boolean_selector
name: boolean_selector
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "
1.0.5
"
version: "
2.0.0
"
charcode:
charcode:
dependency: transitive
dependency: transitive
description:
description:
name: charcode
name: charcode
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "1.1.
2
"
version: "1.1.
3
"
collection:
collection:
dependency: transitive
dependency: transitive
description:
description:
name: collection
name: collection
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "1.14.1
1
"
version: "1.14.1
2
"
convert:
convert:
dependency: transitive
dependency: transitive
description:
description:
...
@@ -56,7 +56,7 @@ packages:
...
@@ -56,7 +56,7 @@ packages:
name: crypto
name: crypto
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "2.1.
3
"
version: "2.1.
4
"
cupertino_icons:
cupertino_icons:
dependency: "direct main"
dependency: "direct main"
description:
description:
...
@@ -113,7 +113,7 @@ packages:
...
@@ -113,7 +113,7 @@ packages:
name: image
name: image
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "2.1.
4
"
version: "2.1.
12
"
intl:
intl:
dependency: transitive
dependency: transitive
description:
description:
...
@@ -204,7 +204,7 @@ packages:
...
@@ -204,7 +204,7 @@ packages:
name: quiver
name: quiver
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "2.
0.5
"
version: "2.
1.3
"
rflutter_alert:
rflutter_alert:
dependency: "direct main"
dependency: "direct main"
description:
description:
...
@@ -258,7 +258,7 @@ packages:
...
@@ -258,7 +258,7 @@ packages:
name: source_span
name: source_span
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "1.
5.5
"
version: "1.
7.0
"
stack_trace:
stack_trace:
dependency: transitive
dependency: transitive
description:
description:
...
@@ -293,7 +293,7 @@ packages:
...
@@ -293,7 +293,7 @@ packages:
name: test_api
name: test_api
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "0.2.1
1
"
version: "0.2.1
5
"
typed_data:
typed_data:
dependency: transitive
dependency: transitive
description:
description:
...
@@ -321,7 +321,7 @@ packages:
...
@@ -321,7 +321,7 @@ packages:
name: xml
name: xml
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "3.
5.0
"
version: "3.
6.1
"
sdks:
sdks:
dart: ">=2.6.0 <3.0.0"
dart: ">=2.6.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment