check web and tablet for logic

This commit is contained in:
amirrezaghabeli
2025-08-23 15:22:28 +03:30
parent b00ba07122
commit 14ab9a75ca
27 changed files with 569 additions and 282 deletions
+18 -15
View File
@@ -1,3 +1,5 @@
import 'package:flutter/foundation.dart';
class AppConfig {
// این فلگ نشان می‌دهد که آیا برنامه در حالت Development است یا خیر.
// می‌توانید این مقدار را با استفاده از environment variables در زمان بیلد تغییر دهید.
@@ -8,23 +10,24 @@ class AppConfig {
// این متد بر اساس محیط فعال، URL مناسب را برمی‌گرداند.
static String get apiBaseUrl {
return 'http://10.0.2.2:8081';
// return 'http:127.0.0.1';
// return 'http://10.0.2.2:8081';
// return '192.168.1.103:8081';
// if (isDevelopment) {
// // Handle different platforms for local development
// if (kIsWeb) {
// // For web, use localhost
// return 'http://localhost:8081';
// } else if (Platform.isAndroid) {
// // For Android emulator, use 10.0.2.2 (special IP for host machine)
// return 'http://10.0.2.2:8081';
// } else if (Platform.isIOS) {
// // For iOS simulator, use localhost
// return 'http://localhost:8081';
// } else {
// // For other platforms (desktop), use localhost
// return 'http://localhost:8081';
// }
if (kIsWeb) {
// For web, use localhost
return 'http://localhost:8081';
} else {
// For Android emulator, use 10.0.2.2 (special IP for host machine)
return 'http://10.0.2.2:8081';
}
// else if (Platform.isIOS) {
// // For iOS simulator, use localhost
// return 'http://localhost:8081';
// } else {
// // For other platforms (desktop), use localhost
// return 'http://localhost:8081';
// }
// } else {
// // Production URL - replace with your actual production server
// return 'https://your-production-server.com';
+4
View File
@@ -1,6 +1,10 @@
class AssetsManager {
AssetsManager._();
//logo
static const logoSmall = 'assets/icons/logo_small.svg';
static const logoBig = 'assets/icons/logo_big.svg';
//bottom navigation
static const homeActive = 'assets/icons/home_active.svg';
static const home = 'assets/icons/home.svg';
+15 -9
View File
@@ -1,5 +1,7 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
class NetworkConnectivity {
static final NetworkConnectivity _instance = NetworkConnectivity._internal();
factory NetworkConnectivity() => _instance;
@@ -7,15 +9,19 @@ class NetworkConnectivity {
/// Check if device has internet connectivity
Future<bool> hasInternetConnection() async {
try {
// Try to reach a reliable host to check internet connectivity
final result = await InternetAddress.lookup('google.com');
return result.isNotEmpty && result[0].rawAddress.isNotEmpty;
} on SocketException catch (_) {
return false;
} on Exception catch (_) {
// If connectivity check fails, assume no connection
return false;
if (kIsWeb) {
return true;
} else {
try {
// Try to reach a reliable host to check internet connectivity
final result = await InternetAddress.lookup('google.com');
return result.isNotEmpty && result[0].rawAddress.isNotEmpty;
} on SocketException catch (_) {
return false;
} on Exception catch (_) {
// If connectivity check fails, assume no connection
return false;
}
}
}
}
+2 -1
View File
@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:dio/dio.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../config/app_config.dart';
import '../utils/logger.dart';
import '../utils/result.dart';
import 'app_exceptions.dart';
@@ -16,7 +17,7 @@ class NetworkManager {
NetworkManager()
: mainDio = Dio(
BaseOptions(
baseUrl: 'http://10.0.2.2:8081',
baseUrl: AppConfig.apiBaseUrl,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
@@ -38,7 +38,7 @@ class DesktopShellPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(width: 40),
Image.asset(AssetsManager.logo, width: 59, height: 28),
SvgPicture.asset(AssetsManager.logoSmall),
Spacer(),
_bottomNavigationItem(
context: context,
@@ -67,7 +67,7 @@ class DesktopShellPage extends StatelessWidget {
activeIconPath: AssetsManager.profileActive,
),
Spacer(),
SizedBox(width: 59),
SizedBox(width: 68),
],
),
);
@@ -84,7 +84,7 @@ class DesktopShellPage extends StatelessWidget {
return InkWell(
onTap: onTap,
child: SizedBox(
width: 200.0,
width: 100.0,
height: 64,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
@@ -38,11 +38,7 @@ class TabletShellPage extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset(
AssetsManager.logo,
width: 59.0.w(),
height: 28.0.h(),
),
SvgPicture.asset(AssetsManager.logoSmall),
InkWell(
onTap: () => _key.currentState!.openDrawer(),
child: SvgPicture.asset(AssetsManager.menu),