This commit is contained in:
2020-12-28 00:19:04 -05:00
parent 86c845b49b
commit c378a6203c
33 changed files with 833 additions and 200 deletions

View File

@@ -0,0 +1,6 @@
extension StringCap on String {
String get firstCap => '${this[0].toUpperCase()}${this.substring(1)}';
String get allCaps => this.toUpperCase();
String get eachFirstCap => this.split(" ").map((str) => str.firstCap).join(" ");
}

View File

@@ -35,9 +35,10 @@ class HttpUtil {
'Http-Business-Id': '0',
'Http-App-Key': '',
'Http-Contact-Authorization': '',
'Http-Device-Type': Platform.isIOS ? 'ios' : (Platform.isAndroid ? 'android' : 'web'),
'Http-Device-Type': Utils.getOs(checkWeb: true),
'Http-Api-Branch': 'flutter',
'Http-Language-Code': store.state.locale.languageCode,
'Http-Country-Code': store.state.locale.countryCode,
};
static Future<dynamic> httpGet(String url,

View File

@@ -12,6 +12,7 @@ import 'package:hive/hive.dart';
import 'package:intl/intl.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:universal_io/io.dart';
import '../constants.dart';
import 'util_web.dart' if (dart.library.io) 'util_io.dart';
import '../routes.dart';
@@ -267,6 +268,47 @@ class Utils {
onError(error);
});
}
static String getOs({bool checkWeb = false}) {
if (checkWeb && kIsWeb) {
return 'web';
}
if (Platform.isAndroid) {
return 'android';
}
if (Platform.isIOS) {
return 'ios';
}
if (Platform.isLinux) {
return 'ubuntu';
}
if (Platform.isMacOS) {
return 'mac';
}
if (Platform.isWindows) {
return 'windows';
}
return 'web';
}
static int getOsFontHex(String os) {
if (os == 'mac') {
return Constants.FONT_APPLE;
}
if (os == 'windows') {
return Constants.FONT_WINDOWS;
}
if (os == 'ubuntu') {
return Constants.FONT_UBUNTU;
}
if (os == 'android') {
return Constants.FONT_ANDROID;
}
if (os == 'ios') {
return Constants.FONT_IOS;
}
return Constants.FONT_TOPTONS;
}
}
class RuntimeError extends Error{