diff --git a/android/app/build.gradle b/android/app/build.gradle index b341872..46ee066 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,46 +1,36 @@ plugins { id "com.android.application" - // START: FlutterFire Configuration - id 'com.google.gms.google-services' - // END: FlutterFire Configuration id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id "dev.flutter.flutter-gradle-plugin" } def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') +def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> + localPropertiesFile.withReader("UTF-8") { reader -> localProperties.load(reader) } } -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = '1' + flutterVersionCode = "1" } -def flutterVersionName = localProperties.getProperty('flutter.versionName') +def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = '1.0' + flutterVersionName = "1.0" } android { - namespace "com.example.sefer_admin1" - compileSdk flutter.compileSdkVersion - ndkVersion flutter.ndkVersion + namespace = "com.example.sefer_admin1" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = '1.8' - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } defaultConfig { @@ -48,23 +38,22 @@ android { applicationId "com.example.sefer_admin1" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - minSdkVersion 23 - targetSdkVersion flutter.targetSdkVersion - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName + minSdk = 23 + targetSdk = flutter.targetSdkVersion + versionCode = flutterVersionCode.toInteger() + versionName = flutterVersionName } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfig = signingConfigs.debug } } } flutter { - source '../..' + source = "../.." } -dependencies {} diff --git a/android/build.gradle b/android/build.gradle index f9e7f92..d2ffbff 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,17 +1,3 @@ -buildscript { - ext.kotlin_version = '2.0.0' // Update to the latest version - - repositories { - google() - mavenCentral() - } - - dependencies { - classpath "com.android.tools.build:gradle:8.1.4" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() @@ -19,12 +5,12 @@ allprojects { } } -rootProject.buildDir = '../build' +rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } tasks.register("clean", Delete) { diff --git a/android/gradle.properties b/android/gradle.properties index 598d13f..73c3168 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,6 @@ org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index a6c0c1c..11fce01 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip diff --git a/android/settings.gradle b/android/settings.gradle index 816dbe0..dc2d592 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -19,7 +19,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "7.3.0" apply false + id "com.android.application" version '8.4.0' apply false // START: FlutterFire Configuration id "com.google.gms.google-services" version "4.3.15" apply false // END: FlutterFire Configuration diff --git a/lib/constant/links.dart b/lib/constant/links.dart index c51f7a9..95c0a3e 100644 --- a/lib/constant/links.dart +++ b/lib/constant/links.dart @@ -222,4 +222,8 @@ class AppLink { static String getRidesPerMonth = "$server/Admin/AdminRide/getRidesPerMonth.php"; static String getRidesDetails = "$server/Admin/AdminRide/get.php"; + static String getPassengersStatic = + "https://api.sefer.live/sefer/serviceApp/getPassengersStatic.php"; + static String getdriverstotalMonthly = + "https://api.sefer.live/sefer/serviceApp/getdriverstotalMonthly.php"; } diff --git a/lib/controller/admin/dashboard_controller.dart b/lib/controller/admin/dashboard_controller.dart index 71d152a..c2251fa 100644 --- a/lib/controller/admin/dashboard_controller.dart +++ b/lib/controller/admin/dashboard_controller.dart @@ -10,6 +10,7 @@ class DashboardController extends GetxController { bool isLoading = false; List dashbord = []; int creditSMS = 0; + Future getDashBoard() async { isLoading = true; update(); @@ -31,8 +32,9 @@ class DashboardController extends GetxController { } @override - void onInit() { + void onInit() async { getDashBoard(); + super.onInit(); } } diff --git a/lib/controller/admin/static_controller.dart b/lib/controller/admin/static_controller.dart new file mode 100644 index 0000000..83c0870 --- /dev/null +++ b/lib/controller/admin/static_controller.dart @@ -0,0 +1,79 @@ +import 'dart:convert'; + +import 'package:fl_chart/fl_chart.dart'; +import 'package:get/get.dart'; + +import '../../constant/links.dart'; +import '../../models/model/passengers_model.dart'; +import '../functions/crud.dart'; + +class StaticController extends GetxController { + Map jsonData1 = {}; + Map jsonData2 = {}; + var chartDataPassengers; + var chartDataDrivers; + bool isLoading = false; + String totalMonthlyPassengers = ''; + String totalMonthlyDrivers = ''; + late List passengersData; + late List driversData; + + Future fetch() async { + isLoading = true; + update(); // Notify the observers about the loading state change + + var res = await CRUD().get( + link: AppLink.getPassengersStatic, + payload: {}, + ); + jsonData1 = jsonDecode(res); + var jsonResponse = jsonDecode(res) as Map; + isLoading = false; + final List jsonData = jsonResponse['message']; + totalMonthlyPassengers = jsonData[0]['totalMonthly'].toString(); + passengersData = jsonData.map((item) { + return MonthlyPassengerInstall.fromJson(item); + }).toList(); + final List spots = passengersData + .map((data) => FlSpot( + data.day.toDouble(), + data.totalPassengers.toDouble(), + )) + .toList(); + chartDataPassengers = spots; + + update(); // Notify the observers about the data and loading state change + } + + Future fetchDrivers() async { + isLoading = true; + update(); // Notify the observers about the loading state change + + var res = await CRUD().get( + link: AppLink.getdriverstotalMonthly, + payload: {}, + ); + jsonData2 = jsonDecode(res); + var jsonResponse = jsonDecode(res) as Map; + isLoading = false; + final List jsonData = jsonResponse['message']; + totalMonthlyDrivers = jsonData[0]['totalMonthly'].toString(); + driversData = jsonData.map((item) { + return MonthlyDriverInstall.fromJson(item); + }).toList(); + final List spots = driversData + .map((data) => FlSpot( + data.day.toDouble(), + data.totalDrivers.toDouble(), + )) + .toList(); + chartDataDrivers = spots; + + update(); // Notify the observers about the data and loading state change + } + + Future getAll() async { + await fetch(); + await fetchDrivers(); + } +} diff --git a/lib/controller/bank_account/payout.dart b/lib/controller/bank_account/payout.dart index dadd402..0001a96 100644 --- a/lib/controller/bank_account/payout.dart +++ b/lib/controller/bank_account/payout.dart @@ -4,6 +4,7 @@ import 'package:get/get.dart'; import 'package:http/http.dart' as http; import '../../../constant/links.dart'; +import '../../constant/api_key.dart'; import '../../constant/box_name.dart'; import '../../constant/colors.dart'; import '../../main.dart'; @@ -21,15 +22,13 @@ class PaymobPayout extends GetxController { }; var body = { 'grant_type': 'password', - 'username': 'sefer_api_checker', - 'password': '#c3pSwbUxOKpQnr5hHZAgpkSW', - 'client_id': 'kmNWU5gKsL8LKVhsJFbOGTEb3YQ5sQhvBoB8pqoW', - 'client_secret': - 'htV6nFANLDd658ueTEuMrIqwjcXsocMXmBLAYof7FuutBcSxdTdoNqFl3EAvO6zrOgGPLdiMrofNp2V9ASVRpjoSlFjDNRzY7hfPunAJEgf2N5ZUuknN4QniaqIZvaNt' + 'username': AK.payMobOutUserName, + 'password': AK.payMobOutPassword, + 'client_id': AK.payMobOutClient_id, + 'client_secret': AK.payMobOutClientSecrret }; var res = await http.post( - Uri.parse( - 'https://stagingpayouts.paymobsolutions.com/api/secure/o/token/'), + Uri.parse('https://payouts.paymobsolutions.com/api/secure/o/token/'), headers: headers, body: body, ); @@ -53,8 +52,7 @@ class PaymobPayout extends GetxController { "msisdn": msisdn, // "01023456789" }); var res = await http.post( - Uri.parse( - 'https://stagingpayouts.paymobsolutions.com/api/secure/disburse/'), + Uri.parse('https://payouts.paymobsolutions.com/api/secure/disburse/'), headers: headers, body: body, ); @@ -64,7 +62,7 @@ class PaymobPayout extends GetxController { 'rideId': DateTime.now().toIso8601String(), 'amount': ((-1) * (double.parse(dec['amount'])) + 5).toStringAsFixed(0), 'payment_method': 'payout', - 'passengerID': 'myself', + 'passengerID': 'admin', 'driverID': box.read(BoxName.driverID).toString(), }); Get.snackbar('Transaction successful'.tr, @@ -94,8 +92,7 @@ class PaymobPayout extends GetxController { }; var res = await http .post( - Uri.parse( - 'https://stagingpayouts.paymobsolutions.com/api/secure/disburse/'), + Uri.parse('https://payouts.paymobsolutions.com/api/secure/disburse/'), headers: headers, body: body, ) diff --git a/lib/models/model/passengers_model.dart b/lib/models/model/passengers_model.dart new file mode 100644 index 0000000..32a903a --- /dev/null +++ b/lib/models/model/passengers_model.dart @@ -0,0 +1,25 @@ +class MonthlyPassengerInstall { + int day; + int totalPassengers; + + MonthlyPassengerInstall({required this.day, required this.totalPassengers}); + + factory MonthlyPassengerInstall.fromJson(Map json) => + MonthlyPassengerInstall( + day: int.parse(json['day'].toString().split('-')[2]), + totalPassengers: + int.parse(json['totalPassengers'].toString().split(':')[0])); +} + +class MonthlyDriverInstall { + int day; + int totalDrivers; + + MonthlyDriverInstall({required this.day, required this.totalDrivers}); + + factory MonthlyDriverInstall.fromJson(Map json) => + MonthlyDriverInstall( + day: int.parse(json['day'].toString().split('-')[2]), + totalDrivers: + int.parse(json['totalDrivers'].toString().split(':')[0])); +} diff --git a/lib/views/admin/admin_home_page.dart b/lib/views/admin/admin_home_page.dart index d5f85a6..232eed4 100644 --- a/lib/views/admin/admin_home_page.dart +++ b/lib/views/admin/admin_home_page.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:get/get_rx/src/rx_typedefs/rx_typedefs.dart'; +import 'package:sefer_admin1/constant/colors.dart'; import 'package:sefer_admin1/controller/admin/dashboard_controller.dart'; +import 'package:sefer_admin1/controller/admin/static_controller.dart'; import 'package:sefer_admin1/controller/notification_controller.dart'; import 'package:sefer_admin1/views/widgets/mycircular.dart'; @@ -25,6 +27,15 @@ class AdminHomePage extends StatelessWidget { return MyScafolld( title: 'Admin Home Page', + action: IconButton( + onPressed: () async { + await Get.find().getDashBoard(); + }, + icon: const Icon( + Icons.refresh, + color: AppColor.greenColor, + ), + ), body: [ GetBuilder(builder: (dashboardController) { return dashboardController.dashbord.isEmpty @@ -318,8 +329,13 @@ class AdminHomePage extends StatelessWidget { onPressed: () => Get.to(() => Rides(), transition: Transition.downToUp)), AdminWidgetsDashBoard( - title: 'Static', - onPressed: () => Get.to(() => const StaticDash())), + title: 'Static', + onPressed: () async { + await Get.put(StaticController()).getAll(); + + Get.to(() => const StaticDash()); + }, + ), AdminWidgetsDashBoard( title: 'send notification Drivers', onPressed: () async { diff --git a/lib/views/admin/static/static.dart b/lib/views/admin/static/static.dart index 6578c79..d53a782 100644 --- a/lib/views/admin/static/static.dart +++ b/lib/views/admin/static/static.dart @@ -1,6 +1,10 @@ +import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:sefer_admin1/constant/style.dart'; +import 'package:sefer_admin1/controller/admin/static_controller.dart'; +import '../../../constant/colors.dart'; import '../../widgets/my_scafold.dart'; class StaticDash extends StatelessWidget { @@ -8,6 +12,193 @@ class StaticDash extends StatelessWidget { @override Widget build(BuildContext context) { - return MyScafolld(title: 'Static Dash'.tr, body: [], isleading: true); + Get.put(StaticController()); + return MyScafolld( + title: 'Static Dash'.tr, + body: [ + GetBuilder(builder: (staticController) { + return Column( + children: [ + Container( + height: Get.height * .3, + width: double.maxFinite, + // decoration: AppStyle.boxDecoration1, + child: Padding( + padding: const EdgeInsets.all(6), + child: Container( + decoration: AppStyle.boxDecoration1, + height: MediaQuery.of(context).size.height * 0.4, + child: LineChart( + LineChartData( + lineBarsData: [ + LineChartBarData( + isStepLineChart: true, + spots: staticController.chartDataPassengers, + isCurved: true, + color: Colors.deepPurpleAccent, // Custom color + barWidth: 3, // Thinner line + dotData: const FlDotData( + show: true), // Show dots on each point + belowBarData: BarAreaData( + show: true, + color: Colors.deepPurpleAccent.withOpacity( + 0.3), // Custom gradient color + ), + isStrokeJoinRound: true, + shadow: const BoxShadow( + color: Colors.yellow, + blurRadius: 4, + offset: Offset(2, 2), + ), + ), + ], + showingTooltipIndicators: const [], + titlesData: FlTitlesData( + show: true, + topTitles: AxisTitles( + axisNameWidget: Text( + 'Days'.tr, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold), + ), + axisNameSize: 30, + ), + bottomTitles: AxisTitles( + axisNameWidget: Text( + 'Total passengers on month ${staticController.totalMonthlyPassengers}' + .tr, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold), + ), + axisNameSize: 30, + sideTitles: const SideTitles( + reservedSize: 30, + showTitles: true, + ), + ), + leftTitles: AxisTitles( + axisNameWidget: Text( + 'Counts of Passengers on days'.tr, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold), + ), + axisNameSize: 30, + sideTitles: const SideTitles( + reservedSize: 30, + showTitles: true, + ), + ), + ), + gridData: const FlGridData(show: true), + borderData: FlBorderData( + show: true, + border: const Border( + bottom: BorderSide(color: Colors.blueAccent), + left: BorderSide(color: Colors.blueAccent), + ), + ), + ), + ), + ), + )), + const SizedBox( + height: 5, + ), + Container( + height: Get.height * .3, + width: double.maxFinite, + // decoration: AppStyle.boxDecoration1, + child: Padding( + padding: const EdgeInsets.all(6), + child: Container( + decoration: AppStyle.boxDecoration1, + height: MediaQuery.of(context).size.height * 0.4, + child: LineChart( + LineChartData( + lineBarsData: [ + LineChartBarData( + isStepLineChart: true, + spots: staticController.chartDataDrivers, + isCurved: true, + color: Colors.deepPurpleAccent, // Custom color + barWidth: 3, // Thinner line + dotData: const FlDotData( + show: true), // Show dots on each point + belowBarData: BarAreaData( + show: true, + color: Colors.deepPurpleAccent.withOpacity( + 0.3), // Custom gradient color + ), + isStrokeJoinRound: true, + shadow: const BoxShadow( + color: Colors.yellow, + blurRadius: 4, + offset: Offset(2, 2), + ), + ), + ], + showingTooltipIndicators: const [], + titlesData: FlTitlesData( + show: true, + topTitles: AxisTitles( + axisNameWidget: Text( + 'Days'.tr, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold), + ), + axisNameSize: 30, + ), + bottomTitles: AxisTitles( + axisNameWidget: Text( + 'Total Drivers on month ${staticController.totalMonthlyDrivers}' + .tr, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold), + ), + axisNameSize: 30, + sideTitles: const SideTitles( + reservedSize: 30, + showTitles: true, + ), + ), + leftTitles: AxisTitles( + axisNameWidget: Text( + 'Counts of Drivers on days'.tr, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold), + ), + axisNameSize: 30, + sideTitles: const SideTitles( + reservedSize: 30, + showTitles: true, + ), + ), + ), + gridData: const FlGridData(show: true), + borderData: FlBorderData( + show: true, + border: const Border( + bottom: BorderSide(color: Colors.blueAccent), + left: BorderSide(color: Colors.blueAccent), + ), + ), + ), + ), + ), + )), + const SizedBox( + height: 5, + ), + ], + ); + }) + ], + isleading: true); } } diff --git a/pubspec.lock b/pubspec.lock index 143ca34..ae16ae5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -588,26 +588,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -708,10 +708,10 @@ packages: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" mime: dependency: transitive description: @@ -945,10 +945,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" timing: dependency: transitive description: @@ -1041,10 +1041,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.1" watcher: dependency: transitive description: