181186 - Criar PDV Android para rodar em maquinas P.O.S.
This commit is contained in:
commit
c9983cbad5
204 files changed
+11453
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
abstract interface class AppVersionProvider {
|
||||
Future<String> getVersion();
|
||||
}
|
||||
|
||||
class PackageInfoAppVersionProvider implements AppVersionProvider {
|
||||
const PackageInfoAppVersionProvider();
|
||||
|
||||
@override
|
||||
Future<String> getVersion() async {
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
return packageInfo.version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
|
||||
import '../../domain/entities/pos_device.dart';
|
||||
|
||||
abstract interface class PosDeviceProvider {
|
||||
Future<PosDevice> getDevice();
|
||||
}
|
||||
|
||||
class PlatformPosDeviceProvider implements PosDeviceProvider {
|
||||
PlatformPosDeviceProvider({DeviceInfoPlugin? plugin})
|
||||
: _plugin = plugin ?? DeviceInfoPlugin();
|
||||
|
||||
final DeviceInfoPlugin _plugin;
|
||||
|
||||
@override
|
||||
Future<PosDevice> getDevice() async {
|
||||
if (!Platform.isAndroid) {
|
||||
return PosDevice(platform: Platform.operatingSystem);
|
||||
}
|
||||
final info = await _plugin.androidInfo;
|
||||
return PosDevice(
|
||||
platform: 'android',
|
||||
serial: info.id,
|
||||
model: info.model,
|
||||
brand: info.brand,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
class ServerUrlValidator {
|
||||
ServerUrlValidator._();
|
||||
|
||||
static String? validate(String value, {bool requireHttps = false}) {
|
||||
final trimmed = value.trim();
|
||||
if (trimmed.isEmpty) {
|
||||
return 'Informe a URL do servidor.';
|
||||
}
|
||||
|
||||
final uri = Uri.tryParse(trimmed);
|
||||
if (uri == null || !uri.hasAuthority || uri.host.isEmpty) {
|
||||
return 'Informe uma URL válida, incluindo o host.';
|
||||
}
|
||||
if (uri.scheme != 'https' && uri.scheme != 'http') {
|
||||
return 'A URL deve usar HTTP ou HTTPS.';
|
||||
}
|
||||
if (requireHttps && uri.scheme != 'https') {
|
||||
return 'Use uma URL HTTPS para proteger a conexão.';
|
||||
}
|
||||
if (uri.userInfo.isNotEmpty || uri.hasFragment) {
|
||||
return 'A URL não pode conter credenciais ou fragmentos.';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user