From 60aee74146f4119d8ba3cc46657a7ba891c52441 Mon Sep 17 00:00:00 2001 From: Hitesh Ale Date: Sun, 26 Feb 2023 14:17:19 -0500 Subject: [PATCH] stripe kill me --- android/app/src/main/AndroidManifest.xml | 8 ++ ios/Runner/Info.plist | 2 + lib/my_webview.dart | 40 ++++++++ lib/profile_screen_custom.dart | 45 ++++++++- linux/flutter/generated_plugin_registrant.cc | 4 + linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 96 +++++++++++++++++++ pubspec.yaml | 2 + .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 11 files changed, 200 insertions(+), 4 deletions(-) create mode 100644 lib/my_webview.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index eb7c267..a11c947 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,13 @@ + + + + + + + + $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName Ruswipeshare + io.flutter.embedded_views_preview + YES CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/lib/my_webview.dart b/lib/my_webview.dart new file mode 100644 index 0000000..68d6aa0 --- /dev/null +++ b/lib/my_webview.dart @@ -0,0 +1,40 @@ + + +import 'package:flutter/material.dart'; +import 'package:webview_flutter/webview_flutter.dart'; + +class WebViewApp extends StatefulWidget { + String selectedUrl = ""; + + WebViewApp({required this.selectedUrl}); + + + @override + State createState() => _WebViewAppState(); +} + +class _WebViewAppState extends State { + late final WebViewController controller; + + String get selectedUrl => selectedUrl; + @override + void initState() { + super.initState(); + controller = WebViewController() + ..loadRequest( + Uri.parse(selectedUrl), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Flutter WebView'), + ), + body: WebViewWidget( + controller: controller, + ), + ); + } +} \ No newline at end of file diff --git a/lib/profile_screen_custom.dart b/lib/profile_screen_custom.dart index 16b3ca2..2d046a2 100644 --- a/lib/profile_screen_custom.dart +++ b/lib/profile_screen_custom.dart @@ -5,7 +5,7 @@ // ignore_for_file: implementation_imports import 'dart:convert'; - +import 'package:url_launcher/url_launcher.dart'; import 'package:firebase_auth/firebase_auth.dart' show ActionCodeSettings, FirebaseAuth, FirebaseAuthException, User; import 'package:flutter/cupertino.dart' hide Title; @@ -18,7 +18,7 @@ import 'package:flutter_stripe/flutter_stripe.dart'; import 'package:http/http.dart' as http; import 'package:flutterfire_ui/auth.dart'; import 'package:flutterfire_ui/src/auth/widgets/internal/loading_button.dart'; - +import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutterfire_ui/src/auth/widgets/internal/universal_button.dart'; import 'package:flutterfire_ui/src/auth/screens/internal/multi_provider_screen.dart'; @@ -28,6 +28,8 @@ import 'package:flutterfire_ui/src/auth/widgets/internal/subtitle.dart'; import 'package:flutterfire_ui/src/auth/widgets/internal/universal_icon_button.dart'; import 'package:ruswipeshare/credit_view.dart'; +import 'my_webview.dart'; + class EditButton extends StatelessWidget { final bool isEditing; final VoidCallback? onPressed; @@ -273,8 +275,24 @@ class ProfileScreenCustom extends MultiProviderScreen { foregroundColor: MaterialStateProperty.all(Colors.red), ), onPressed: () async { - - + var Ddata = await http.get(Uri.parse('http://172.20.10.2:5000/setup-seller')); + var data = jsonDecode(Ddata.body); + String url = data['url']; + final uri = Uri.parse(url); + + await launchUrl(uri); +final FirebaseAuth auth = FirebaseAuth.instance; + final User? user = auth.currentUser; + final uid = user?.uid; + String acc = ""; +for(String element in url.split("/")){ +if(element.contains("acc")) + acc = element; +} + CollectionReference users = FirebaseFirestore.instance.collection('users'); + users.add(ASell(acc, uid)); + + /* try { // 1. create payment intent on the server @@ -307,6 +325,7 @@ class ProfileScreenCustom extends MultiProviderScreen { } await Stripe.instance.presentPaymentSheet(); + */ }, child: Text('Setup Seller'), @@ -362,3 +381,21 @@ class ProfileScreenCustom extends MultiProviderScreen { ); } } + +class ASell implements Comparable { + String suid = ""; + String? uid = ""; + + + ASell(this.suid, String? this.uid, ); + + @override + String toString() { + return "Suid: $suid, uid: $uid"; + } + + @override + int compareTo(ASell other) { + return suid.compareTo(other.suid); + } +} \ No newline at end of file diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 1c65bab..f10ce1c 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,9 +7,13 @@ #include "generated_plugin_registrant.h" #include +#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) desktop_webview_auth_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopWebviewAuthPlugin"); desktop_webview_auth_plugin_register_with_registrar(desktop_webview_auth_registrar); + 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 e5bf8b2..918b6b4 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST desktop_webview_auth + url_launcher_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index f9fe25e..35c1392 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -14,6 +14,7 @@ import geolocator_apple import path_provider_foundation import sign_in_with_apple import twitter_login +import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) @@ -25,4 +26,5 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SignInWithApplePlugin.register(with: registry.registrar(forPlugin: "SignInWithApplePlugin")) TwitterLoginPlugin.register(with: registry.registrar(forPlugin: "TwitterLoginPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 333457d..bfd356a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -762,6 +762,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: "75f2846facd11168d007529d6cd8fcb2b750186bea046af9711f10b907e1587e" + url: "https://pub.dev" + source: hosted + version: "6.1.10" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "1f4d9ebe86f333c15d318f81dcdc08b01d45da44af74552608455ebdc08d9732" + url: "https://pub.dev" + source: hosted + version: "6.0.24" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: c9cd648d2f7ab56968e049d4e9116f96a85517f1dd806b96a86ea1018a3a82e5 + url: "https://pub.dev" + source: hosted + version: "6.1.1" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: e29039160ab3730e42f3d811dc2a6d5f2864b90a70fb765ea60144b03307f682 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "2dddb3291a57b074dade66b5e07e64401dd2487caefd4e9e2f467138d8c7eb06" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "6c9ca697a5ae218ce56cece69d46128169a58aa8653c1b01d26fcd4aad8c4370" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "574cfbe2390666003c3a1d129bdc4574aaa6728f0c00a4829a81c316de69dd9b" + url: "https://pub.dev" + source: hosted + version: "2.0.15" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "97c9067950a0d09cbd93e2e3f0383d1403989362b97102fbf446473a48079a4b" + url: "https://pub.dev" + source: hosted + version: "3.0.4" vector_math: dependency: transitive description: @@ -770,6 +834,38 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + webview_flutter: + dependency: "direct main" + description: + name: webview_flutter + sha256: "9ba213434f13e760ea0f175fbc4d6bb6aeafd7dfc6c7d973f15d3e47a5d6686e" + url: "https://pub.dev" + source: hosted + version: "4.0.5" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: "48c8cfb023168473c0a3a4c21ffea6c23a32cc7156701c39f618b303c6a3c96e" + url: "https://pub.dev" + source: hosted + version: "3.3.1" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: df6472164b3f4eaf3280422227f361dc8424b106726b7f21d79a8656ba53f71f + url: "https://pub.dev" + source: hosted + version: "2.0.2" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: "283a38c2a2544768033864c698e0133aa9eee0f2c800f494b538a3d1044f7ecb" + url: "https://pub.dev" + source: hosted + version: "3.1.1" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 3f5e80f..bee0926 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -46,6 +46,8 @@ dependencies: material_dialogs: any google_fonts: ^4.0.3 http: any + webview_flutter: any + url_launcher: ^6.1.7 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 75e23e2..2b33e5b 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -8,10 +8,13 @@ #include #include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { DesktopWebviewAuthPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("DesktopWebviewAuthPlugin")); GeolocatorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("GeolocatorWindows")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 3ff9bdc..677153d 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -5,6 +5,7 @@ list(APPEND FLUTTER_PLUGIN_LIST desktop_webview_auth geolocator_windows + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST