diff --git a/lib/backend/DataManager.dart b/lib/backend/DataManager.dart index 5c04962..8d7f311 100644 --- a/lib/backend/DataManager.dart +++ b/lib/backend/DataManager.dart @@ -262,4 +262,17 @@ class DataManager{ return (response.body.toString()); } + + static Future> GetWithdrawalHistory() async{ + Map body = { + "id": UserJson['id'] + }; + var response = (await http.post( + Uri.parse('${API_ENDPOINT}get_wd_history.php'), + body: body)); + Debug.Log("wd history response: " +response.body.toString()); + + return jsonDecode(response.body.toString()); + } + } \ No newline at end of file diff --git a/lib/home.dart b/lib/home.dart index eee2b8e..f42119a 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -4,6 +4,7 @@ import 'package:fhub/backend/DebugHelper.dart'; import 'package:fhub/backend/Dialogs.dart'; import 'package:fhub/gameInfo.dart'; import 'package:fhub/src/CustomWidgets.dart'; +import 'package:fhub/wd_history.dart'; import 'package:fhub/wd_portal.dart'; import 'package:fhub/welcome.dart'; import 'package:flutter/material.dart'; @@ -404,7 +405,11 @@ class _HomeState extends State with WidgetsBindingObserver { builder: (BuildContext context) => WithdrawalPortal())); }, child: Text("Withdraw"),height: 40, width: 200, color: Colors.greenAccent), - GlassButton(onTap: (){}, child: Icon(Icons.history), width: 60, height: 40) + GlassButton(onTap: (){ + Navigator.of(context).push(MaterialPageRoute( + builder: (BuildContext context) => + WithdrawalHistoryPage())); + }, child: Icon(Icons.history), width: 60, height: 40) ], ) ], diff --git a/lib/wd_history.dart b/lib/wd_history.dart new file mode 100644 index 0000000..68b4c32 --- /dev/null +++ b/lib/wd_history.dart @@ -0,0 +1,168 @@ +import 'package:fhub/backend/DataManager.dart'; +import 'package:fhub/backend/helpers.dart'; +import 'package:fhub/src/CustomWidgets.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class WithdrawalHistoryPage extends StatefulWidget { + const WithdrawalHistoryPage({Key? key}) : super(key: key); + + @override + State createState() => _WithdrawalHistoryPageState(); +} + +class _WithdrawalHistoryPageState extends State { + + @override + void initState() { + // TODO: implement initState + super.initState(); + + kickstartAnimations(); + GetHistory(); + } + List wd_requests = []; + void GetHistory() async{ + wd_requests = await DataManager.GetWithdrawalHistory(); + + loaded =true; + setState(() { + + }); + } + + void kickstartAnimations() async { + await Future.delayed(const Duration(milliseconds: 500)); + + setState(() { + op1 = 0.5; + op2 = 0.5; + op3 = 0.5; + }); + } + bool loaded = false; + ScrollController scrollController = ScrollController(); + @override + Widget build(BuildContext context) { + final screenHeight = MediaQuery.of(context).size.height; + final screenWidth = MediaQuery.of(context).size.width; + return Scaffold( + backgroundColor: Colors.black, + body: CustomBody( + child: SafeArea( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + mainAxisSize: MainAxisSize.max, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Container( + margin: EdgeInsets.all(10), + child: Icon(Icons.keyboard_arrow_left, + size: 50)), + onTap: () { + Navigator.of(context).pop(); + }, + ), + GradientText( + text: "Withdrawal History", + gradient: LinearGradient(colors: [ + Colors.white.withOpacity(0.6), + Colors.white.withOpacity(0.5), + Colors.white.withOpacity(0.2) + ]), + style: TextStyle( + fontSize: 29, + fontWeight: FontWeight.bold), + ), + Container( + width: 40, + ) + ], + ), + SizedBox( + height: 50, + ), + (loaded) ? + Padding( + padding: const EdgeInsets.all(20.0), + child: GlassCard(child: Container( + + height: screenHeight * 0.6, + padding: EdgeInsets.all(12), + child: Column( + children: [ + ListView.builder( + shrinkWrap: true, + controller: scrollController, + itemCount: wd_requests.length, + itemBuilder: (BuildContext context, int index) { + return WdRequestItem( + wd_requests[index]); + }, + ), + ], + ), + )), + ) + :Container(height: screenHeight * 0.6,child: Center(child: Text("Loading..."))) + + ], + ) + ]))), + context: context, + onAnimEnd: () { + kickstartAnimations(); + }), + ); + } + + Widget WdRequestItem(dynamic request) { + DateTime createdTime = DateTime.parse(request['created_time']); + return InkWell( + onTap: (){ + if((request['receipt'].toString() ?? "").contains("http")){ + launchUrl(Uri.parse(request['receipt'])); + } + }, + child: Padding( + padding: const EdgeInsets.all(3.0), + child: GlassCard( + color: Colors.white, + child: Container( + padding: const EdgeInsets.all(10.0), + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [SizedBox(width: 100, child: Text(DateFormat('yyyy-MM-dd').format(createdTime)))], + ), + Row( + children: [ + Text( + "${Helpers.SatsToCoin(int.parse(request['amount'])).toStringAsFixed(8)}"), + SizedBox( + width: 5, + ), + Icon(Helpers.GetIconForCrypto(request['coin'])) + ], + ), + Text(request['status']) + ], + ), + ), + )), + ), + ); + } +} diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index e71a16d..f6f23bf 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 2e1de87..f16b4c3 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 1fb4f92..495c0b1 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,9 +8,11 @@ import Foundation import firebase_auth import firebase_core import shared_preferences_foundation +import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 30d7b8b..ee36a73 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -248,6 +248,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + intl: + dependency: "direct main" + description: + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" js: dependency: transitive description: @@ -469,6 +477,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: eb1e00ab44303d50dd487aab67ebc575456c146c6af44422f9c13889984c00f3 + url: "https://pub.dev" + source: hosted + version: "6.1.11" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "15f5acbf0dce90146a0f5a2c4a002b1814a6303c4c5c075aa2623b2d16156f03" + url: "https://pub.dev" + source: hosted + version: "6.0.36" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "9af7ea73259886b92199f9e42c116072f05ff9bea2dcb339ab935dfc957392c2" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "207f4ddda99b95b4d4868320a352d374b0b7e05eefad95a4a26f57da413443f5" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "91ee3e75ea9dadf38036200c5d3743518f4a5eb77a8d13fda1ee5764373f185e" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: bfdfa402f1f3298637d71ca8ecfe840b4696698213d5346e9d12d4ab647ee2ea + url: "https://pub.dev" + source: hosted + version: "2.1.3" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "6bb1e5d7fe53daf02a8fee85352432a40b1f868a81880e99ec7440113d5cfcab" + url: "https://pub.dev" + source: hosted + version: "2.0.17" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "254708f17f7c20a9c8c471f67d86d76d4a3f9c1591aad1e15292008aceb82771" + url: "https://pub.dev" + source: hosted + version: "3.0.6" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 7c5d377..bff14ac 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,6 +40,8 @@ dependencies: animated_text_kit: ^4.2.2 cupertino_icons: ^1.0.2 external_app_launcher: ^3.1.0 + url_launcher: ^6.1.11 + intl: ^0.18.1 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 1a82e7d..ec8e8d4 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,8 +7,11 @@ #include "generated_plugin_registrant.h" #include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { FirebaseCorePluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index fa8a39b..02d26c3 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST firebase_core + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST