Skip to content

Commit

Permalink
Đăng ký danh sách
Browse files Browse the repository at this point in the history
  • Loading branch information
webvang committed Aug 28, 2021
1 parent e3ad137 commit 9753eab
Show file tree
Hide file tree
Showing 16 changed files with 217 additions and 124 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ mobile/Vaccom_Mobile/**/ios/Flutter/app.flx
mobile/Vaccom_Mobile/**/ios/Flutter/app.zip
mobile/Vaccom_Mobile/**/ios/Flutter/flutter_assets/
mobile/Vaccom_Mobile/**/ios/ServiceDefinitions.json
*mobile/Vaccom_Mobile/*/ios/Runner/GeneratedPluginRegistrant.*
mobile/Vaccom_Mobile/**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!mobile/Vaccom_Mobile/**/ios/**/default.mode1v3
!mobile/Vaccom_Mobile/**/ios/**/default.mode2v3
!mobile/Vaccom_Mobile/**/ios/**/default.pbxuser
!mobile/Vaccom_Mobile/**/ios/**/default.perspectivev3
!mobile/Vaccom_Mobile//packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!mobile/Vaccom_Mobile/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
mobile/Vaccom_Mobile/*.json
mobile/Vaccom_Mobile/.dart_tool/version
mobile/Vaccom_Mobile/.dart_tool/package_config_subset
mobile/Vaccom_Mobile/.dart_tool/**
mobile/Vaccom_Mobile/*.json
2 changes: 2 additions & 0 deletions mobile/Vaccom_Mobile/.idea/VaccomApp.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mobile/Vaccom_Mobile/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions mobile/Vaccom_Mobile/lib/commons/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:simple_logger/simple_logger.dart';
import 'package:vaccom_mobile/commons/constants.dart';
Expand All @@ -20,6 +21,26 @@ extension EmailValidator on String {
class Utils {
static hideKeyboard() => FocusManager.instance.primaryFocus.unfocus();

static PreferredSize gradientAppBar({Widget child, double height}) {
return PreferredSize(
preferredSize: Size.fromHeight(height ?? AppBar().preferredSize.height),
child: Stack(
children: [
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xFF171cc2), Color(0xFFff5200)],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
),
child,
],
),
);
}

static Future<void> revokeToken() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.remove(AppConstant.accessToken);
Expand Down Expand Up @@ -98,5 +119,51 @@ class Utils {
: null,
)..show();
}

//
static Widget emptyDataWidget({String text = r'Chưa có dữ liệu'}) {
return Column(
children: <Widget>[
SizedBox(height: 64),
Center(
child: Text(
'$text',
textAlign: TextAlign.center,
style: GoogleFonts.openSans(
fontWeight: FontWeight.normal,
fontSize: 13,
fontStyle: FontStyle.italic,
color: Colors.grey,
),
),
)
],
);
}

static String dateTimeNow() {
var now = DateTime.now();
var minute = now.minute < 10 ? '0${now.minute}' : '${now.minute}';
return '${now.day}/${now.month}/${now.year} ${now.hour}:$minute';
}

static Widget completeRefreshWidget = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Icon(
Icons.done,
color: Colors.grey,
),
Container(
width: 10.0,
),
Text(
r'Cập nhật lúc ' + dateTimeNow(),
style: GoogleFonts.openSans(
color: Colors.grey,
),
)
],
);
}

2 changes: 1 addition & 1 deletion mobile/Vaccom_Mobile/lib/model/server_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class ServerInfo {
static ServerInfo vaccom = ServerInfo(
title: r'Vaccom',
desc: r'HỆ THỐNG QUẢN LÝ VÀ TỔ CHỨC ĐIỂM TIÊM CHỦNG',
baseUrl: r'mobile.vaccom.vn:8080/rest/v1/',
baseUrl: r'thachban.vaccom.vn:8080/rest/v1/',
logoBanner: r'https://thachban.vaccom.vn/images/logo_banner.png');
}
11 changes: 9 additions & 2 deletions mobile/Vaccom_Mobile/lib/network/api/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import 'package:http/http.dart' as http;
import 'package:vaccom_mobile/commons/utils.dart';
import 'package:vaccom_mobile/network/exception.dart';
import 'package:vaccom_mobile/network/global.dart';
import 'package:vaccom_mobile/network/response/base.dart';
import 'package:vaccom_mobile/network/response/mapping/user.dart';
import 'package:vaccom_mobile/network/response/response.dart';

export 'mock_api.dart';
export 'remote_api.dart';

part 'api_method.dart';

part 'api_path.dart';

enum ApiType { mock, remote }
Expand All @@ -22,4 +25,8 @@ abstract class API {
Future<VacToken> securityToken({String username, String password});

Future<User> getUser({int userId});
}

Future<InjectorPaging> getListNguoiTiemChung({
Map<String, dynamic> params,
});
}
8 changes: 4 additions & 4 deletions mobile/Vaccom_Mobile/lib/network/api/api_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension ApiMethod on API {
}

static String convertMapToQueryParameter(Map<String, dynamic> params) {
var result = List<String>();
List<String> result = [];
params.forEach((key, value) {
result.add("$key=$value");
});
Expand All @@ -26,7 +26,7 @@ extension ApiMethod on API {
throw NetworkException();
}

logger.info('\n[${api.name}] GET ${api.path} - params: $params');
logger.info('--[${api.name}] GET ${api.path} - params: $params');

var accessToken = await Utils.getAppToken();

Expand Down Expand Up @@ -58,7 +58,7 @@ extension ApiMethod on API {
throw NetworkException();
}

logger.info('\n[${api.name}] POST ${api.path} - params: $params');
logger.info('--[${api.name}] POST ${api.path} - params: $params');

var accessToken = await Utils.getAppToken();

Expand Down Expand Up @@ -112,7 +112,7 @@ extension ApiMethod on API {
static dynamic _processResponse(http.Response response) {
switch (response.statusCode) {
case 200:
var responseJson = json.decode(response.body.toString());
var responseJson = json.decode(response.body);
logger.info(responseJson);
return responseJson;
break;
Expand Down
14 changes: 11 additions & 3 deletions mobile/Vaccom_Mobile/lib/network/api/api_path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ class ApiPath {

ApiPath({this.name, this.path});

static ApiPath login = ApiPath(name: 'Login', path: 'security/login');
static ApiPath login = ApiPath(
name: 'Login',
path: 'security/login',
);

static ApiPath getUser(int id) => ApiPath(
name: r'Chi tiết người dùng',
path: r'app/get/nguoidung/' + '$id',
name: r'Chi tiết người dùng',
path: r'app/get/nguoidung/' + '$id',
);

static ApiPath getListNguoiTiemChung = ApiPath(
name: r'Danh sách người tiêm chủng',
path: r'app/get/search/nguoitiemchung'
);
}
8 changes: 8 additions & 0 deletions mobile/Vaccom_Mobile/lib/network/api/mock_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ class MockAPI implements API {
var data = json.decode(mockUser);
return User.fromJson(data);
}

Future<InjectorPaging> getListNguoiTiemChung({
Map<String, dynamic> params,
}) async {
await Future.delayed(Duration(seconds: 1));
var data = json.decode(mockNguoiTiemChung);
return InjectorPaging.fromJson(data);
}
}
11 changes: 11 additions & 0 deletions mobile/Vaccom_Mobile/lib/network/api/remote_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,15 @@ class RemoteAPI implements API {
throw e;
}
}

Future<InjectorPaging> getListNguoiTiemChung({
Map<String, dynamic> params,
}) async {
try {
var data = await ApiMethod.getData(ApiPath.getListNguoiTiemChung, params);
return InjectorPaging.fromJson(data);
} catch (e) {
throw e;
}
}
}
2 changes: 1 addition & 1 deletion mobile/Vaccom_Mobile/lib/network/mock/mock.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export 'mock_token.dart';
export 'mock_user.dart';
export 'mock_cosoyte.dart';
export 'mock_danhsachdangky.dart';
export 'mock_nguoitiemchung.dart';
export 'mock_dantoc.dart';
export 'mock_diabancoso.dart';
export 'mock_doituong.dart';
Expand Down
2 changes: 1 addition & 1 deletion mobile/Vaccom_Mobile/lib/network/response/response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export 'mapping/cosoyte.dart';
export 'mapping/dantoc.dart';
export 'mapping/diabancoso.dart';
export 'mapping/doituong.dart';
export 'mapping/nguoi_dang_ky.dart';
export 'mapping/nguoitiemchung.dart';
export 'mapping/quanhuyen.dart';
export 'mapping/quocgia.dart';
export 'mapping/tinhthanh.dart';
Expand Down
8 changes: 5 additions & 3 deletions mobile/Vaccom_Mobile/lib/pages/login/login_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ class _LoginPage extends State<LoginPage> {
margin: EdgeInsets.only(
left: padding,
right: padding,
top: 72,
bottom: 10),
top: 80,
bottom: 80),
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Color(0xFFFEFEFE),
Expand Down Expand Up @@ -351,7 +351,9 @@ class _LoginPage extends State<LoginPage> {
),
Positioned(
child: Padding(
padding: EdgeInsets.only(bottom: 100),
padding: EdgeInsets.only(
bottom: 16 + MediaQuery.of(context).padding.bottom,
),
child: serverInfoWidget(),
),
left: 0,
Expand Down
Loading

0 comments on commit 9753eab

Please sign in to comment.