Skip to content

Commit

Permalink
🚀ADD: server's list pages
Browse files Browse the repository at this point in the history
  • Loading branch information
linaaaqi committed Jan 10, 2021
1 parent 1cb6ed3 commit e7faeb0
Show file tree
Hide file tree
Showing 15 changed files with 307 additions and 137 deletions.
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>
9 changes: 9 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Profile;
Expand All @@ -510,6 +511,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = PacketTunnel/PacketTunnel.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 95WRM2QC52;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/PacketTunnel";
Expand All @@ -526,6 +528,7 @@
"$(inherited)",
"$(PROJECT_DIR)/PacketTunnel/libleaf",
);
MARKETING_VERSION = 1.0.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.kanshiyun.sail.PacketTunnel;
Expand All @@ -550,6 +553,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = PacketTunnel/PacketTunnel.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 95WRM2QC52;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/PacketTunnel";
Expand All @@ -566,6 +570,7 @@
"$(inherited)",
"$(PROJECT_DIR)/PacketTunnel/libleaf",
);
MARKETING_VERSION = 1.0.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.kanshiyun.sail.PacketTunnel;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -587,6 +592,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = PacketTunnel/PacketTunnel.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 95WRM2QC52;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/PacketTunnel";
Expand All @@ -603,6 +609,7 @@
"$(inherited)",
"$(PROJECT_DIR)/PacketTunnel/libleaf",
);
MARKETING_VERSION = 1.0.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.kanshiyun.sail.PacketTunnel;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -749,6 +756,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
Expand Down Expand Up @@ -781,6 +789,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
Expand Down
1 change: 1 addition & 0 deletions lib/constant/app_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class AppStrings {
static const String APP_NAME = '瞰视云加速';
static const String TOKEN = 'X-ACCESS-TOKEN';
static const String USER_INFO = 'userInfo';
static const String USER_SUBSCRIBE = 'userInfo';
static const String ERR_NO = 'code';
static const String IS_FIRST = "isFirst";
static const String OPEN_DOOR = '开启加速服务';
Expand Down
1 change: 1 addition & 0 deletions lib/constant/app_urls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ class AppUrls {
static const String REGISTER = '$BASE_URL/passport/auth/register';
static const String USER_SUBSCRIBE = '$BASE_URL/user/getSubscribe';
static const String PLAN = '$BASE_URL/guest/plan/fetch';
static const String SERVER = '$BASE_URL/user/server/fetch';
static const String USER_INFO = '$BASE_URL/user/info';
}
131 changes: 131 additions & 0 deletions lib/entity/server_entity.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// To parse this JSON data, do
//
// final serverEntity = serverEntityFromMap(jsonString);

import 'package:meta/meta.dart';
import 'dart:convert';

List<ServerEntity> serverEntityFromList(List<dynamic> data) => List<ServerEntity>.from(data.map((x) => ServerEntity.fromMap(x)));

class ServerEntity {
ServerEntity({
@required this.id,
@required this.groupId,
@required this.parentId,
@required this.tags,
@required this.name,
@required this.rate,
@required this.host,
@required this.port,
@required this.serverPort,
@required this.cipher,
@required this.show,
@required this.sort,
@required this.createdAt,
@required this.updatedAt,
@required this.type,
@required this.link,
@required this.lastCheckAt,
});

final int id;
final List<String> groupId;
final dynamic parentId;
final List<String> tags;
final String name;
final String rate;
final String host;
final int port;
final int serverPort;
final String cipher;
final int show;
final dynamic sort;
final DateTime createdAt;
final DateTime updatedAt;
final String type;
final String link;
dynamic lastCheckAt;

ServerEntity copyWith({
int id,
List<int> groupId,
dynamic parentId,
List<String> tags,
String name,
String rate,
String host,
int port,
int serverPort,
String cipher,
int show,
dynamic sort,
DateTime createdAt,
DateTime updatedAt,
String type,
String link,
dynamic lastCheckAt,
}) =>
ServerEntity(
id: id ?? this.id,
groupId: groupId ?? this.groupId,
parentId: parentId ?? this.parentId,
tags: tags ?? this.tags,
name: name ?? this.name,
rate: rate ?? this.rate,
host: host ?? this.host,
port: port ?? this.port,
serverPort: serverPort ?? this.serverPort,
cipher: cipher ?? this.cipher,
show: show ?? this.show,
sort: sort ?? this.sort,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
type: type ?? this.type,
link: link ?? this.link,
lastCheckAt: lastCheckAt ?? this.lastCheckAt,
);

factory ServerEntity.fromJson(String str) => ServerEntity.fromMap(json.decode(str));

String toJson() => json.encode(toMap());

factory ServerEntity.fromMap(Map<String, dynamic> map) => ServerEntity(
id: map["id"] == null ? null : map["id"],
groupId: map["group_id"] == null ? null : List<String>.from(json.decode(map["group_id"]).map((x) => x)),
parentId: map["parent_id"],
tags: map["tags"] == null ? null : List<String>.from(json.decode(map["tags"]).map((x) => x)),
name: map["name"] == null ? null : map["name"],
rate: map["rate"] == null ? null : map["rate"],
host: map["host"] == null ? null : map["host"],
port: map["port"] == null ? null : map["port"],
serverPort: map["server_port"] == null ? null : map["server_port"],
cipher: map["cipher"] == null ? null : map["cipher"],
show: map["show"] == null ? null : map["show"],
sort: map["sort"],
createdAt: map["created_at"] == null ? null : DateTime.parse(map["created_at"]),
updatedAt: map["updated_at"] == null ? null : DateTime.parse(map["updated_at"]),
type: map["type"] == null ? null : map["type"],
link: map["link"] == null ? null : map["link"],
lastCheckAt: map["last_check_at"],
);

Map<String, dynamic> toMap() => {
"id": id == null ? null : id,
"group_id": groupId == null ? null : List<dynamic>.from(groupId.map((x) => x)),
"parent_id": parentId,
"tags": tags == null ? null : List<dynamic>.from(tags.map((x) => x)),
"name": name == null ? null : name,
"rate": rate == null ? null : rate,
"host": host == null ? null : host,
"port": port == null ? null : port,
"server_port": serverPort == null ? null : serverPort,
"cipher": cipher == null ? null : cipher,
"show": show == null ? null : show,
"sort": sort,
"created_at": createdAt == null ? null : createdAt.toIso8601String(),
"updated_at": updatedAt == null ? null : updatedAt.toIso8601String(),
"type": type == null ? null : type,
"link": link == null ? null : link,
"last_check_at": lastCheckAt,
};
}
38 changes: 38 additions & 0 deletions lib/models/server_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:sail_app/constant/app_strings.dart';
import 'package:sail_app/entity/server_entity.dart';
import 'package:sail_app/models/base_model.dart';
import 'package:sail_app/service/server_service.dart';
import 'package:sail_app/utils/shared_preferences_util.dart';

class ServerModel extends BaseModel {
List<ServerEntity> _serverEntityList;

ServerService _serverService = ServerService();

List<ServerEntity> get serverEntityList => _serverEntityList;

Future<bool> getServer() async {
bool result = false;

List<ServerEntity> serverEntityList = await _serverService.server();
setServerEntityList(serverEntityList);

notifyListeners();

result = true;

return result;
}

setServerEntityList(List<ServerEntity> serverEntityList) {
_serverEntityList = serverEntityList;

_saveServerEntityList();
}

_saveServerEntityList() async {
SharedPreferencesUtil sharedPreferencesUtil = SharedPreferencesUtil.getInstance();

await sharedPreferencesUtil.setList(AppStrings.USER_INFO, _serverEntityList);
}
}
2 changes: 1 addition & 1 deletion lib/models/user_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class UserModel extends BaseModel {
SharedPreferencesUtil sharedPreferencesUtil = SharedPreferencesUtil.getInstance();

sharedPreferencesUtil.clear();
setIsFirst(false);
// setIsFirst(false);

refreshData();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/models/user_subscribe_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ class UserSubscribeModel extends BaseModel {
_saveUserSubscribe() async {
SharedPreferencesUtil sharedPreferencesUtil = SharedPreferencesUtil.getInstance();

await sharedPreferencesUtil.setMap(AppStrings.USER_INFO, _userSubscribeEntity.toMap());
await sharedPreferencesUtil.setMap(AppStrings.USER_SUBSCRIBE, _userSubscribeEntity.toMap());
}
}
2 changes: 1 addition & 1 deletion lib/pages/login/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class LoginPage extends StatelessWidget {

return FlutterLogin(
title: AppStrings.APP_NAME,
logo: 'assets/usa.png',
logo: 'assets/logo.png',
onLogin: _login,
onSignup: _register,
messages: LoginMessages(
Expand Down
Loading

0 comments on commit e7faeb0

Please sign in to comment.