From d5bdd0e13a1091c2ecc098e977883dee96965e54 Mon Sep 17 00:00:00 2001
From: sousa-p
Date: Wed, 12 Mar 2025 10:31:54 -0300
Subject: [PATCH 1/4] :recycle: adicionando novo sistema de rotas, trocando
pacotes e adicionando nullSafety
---
README.md | 6 +-
android/app/build.gradle | 69 +++------
android/app/src/debug/AndroidManifest.xml | 6 +-
android/app/src/main/AndroidManifest.xml | 19 +--
android/app/src/profile/AndroidManifest.xml | 6 +-
android/build.gradle | 21 +--
.../gradle/wrapper/gradle-wrapper.properties | 3 +-
android/settings.gradle | 30 ++--
lib/auth/lio_deeplink_constants.dart | 4 +
lib/constants.dart | 4 -
.../model/Payment_request.dart | 129 -----------------
.../model/payment_response.dart | 30 ----
.../model/payment_response_success.dart | 136 ------------------
.../payment_checkout/model/payment_type.dart | 1 -
.../payment_checkout_presenter.dart | 69 ---------
.../model/Payment_request.dart | 120 ++++++++++++++++
.../payment_checkout/model/order.dart | 45 +++---
.../payment_checkout/model/payment.dart | 47 +++---
.../model/payment_fields.dart | 92 ++++++------
.../model/payment_response.dart | 32 +++++
.../model/payment_response_success.dart | 135 +++++++++++++++++
.../payment_checkout/model/payment_type.dart | 4 +
.../payment_checkout_presenter.dart | 78 ++++++++++
.../payment_checkout_screen.dart | 67 ++++-----
.../payment_checkout_view.dart | 0
.../products/model/product.dart | 19 ++-
.../products/product_list.dart | 9 +-
lib/main.dart | 11 +-
lib/routes.dart | 24 ----
lib/routing/router.dart | 30 ++++
lib/routing/routes.dart | 4 +
pubspec.yaml | 10 +-
32 files changed, 625 insertions(+), 635 deletions(-)
create mode 100644 lib/auth/lio_deeplink_constants.dart
delete mode 100644 lib/constants.dart
delete mode 100644 lib/feature/payment_checkout/model/Payment_request.dart
delete mode 100644 lib/feature/payment_checkout/model/payment_response.dart
delete mode 100644 lib/feature/payment_checkout/model/payment_response_success.dart
delete mode 100644 lib/feature/payment_checkout/model/payment_type.dart
delete mode 100644 lib/feature/payment_checkout/payment_checkout_presenter.dart
create mode 100644 lib/features/payment_checkout/model/Payment_request.dart
rename lib/{feature => features}/payment_checkout/model/order.dart (58%)
rename lib/{feature => features}/payment_checkout/model/payment.dart (74%)
rename lib/{feature => features}/payment_checkout/model/payment_fields.dart (82%)
create mode 100644 lib/features/payment_checkout/model/payment_response.dart
create mode 100644 lib/features/payment_checkout/model/payment_response_success.dart
create mode 100644 lib/features/payment_checkout/model/payment_type.dart
create mode 100644 lib/features/payment_checkout/payment_checkout_presenter.dart
rename lib/{feature => features}/payment_checkout/payment_checkout_screen.dart (56%)
rename lib/{feature => features}/payment_checkout/payment_checkout_view.dart (100%)
rename lib/{feature => features}/products/model/product.dart (69%)
rename lib/{feature => features}/products/product_list.dart (75%)
delete mode 100644 lib/routes.dart
create mode 100644 lib/routing/router.dart
create mode 100644 lib/routing/routes.dart
diff --git a/README.md b/README.md
index 4476729..f050e91 100644
--- a/README.md
+++ b/README.md
@@ -21,14 +21,14 @@ Manager SDK.
3. Ao término do fluxo de pagamento, o aplicativo do parceiro recebe as informações sobre o pagamento realizado atraves Deep Linking.
## Observações:
-Para fazer uso do exemplo, é necessário alterar os valores das constants, dentro de /lib/contants.dart:
+Para fazer uso do exemplo, é necessário alterar os valores das LioDeepLinkConstants, dentro de /lib/contants.dart:
-* ACCESS_TOKEN: Identificação do token de acesso, que armazena as regras de acesso permitidas ao Client ID.
+* accessToken: Identificação do token de acesso, que armazena as regras de acesso permitidas ao Client ID.
Sua geração ocorre no momento da criação do Client ID pelo painel do desenvolvedor.
Seu valor pode ser visualizado clicando em ‘detalhes’ na coluna ‘Access Tokens’, dentro do menu
['Client ID Cadastrados'](https://desenvolvedores.cielo.com.br/api-portal/myapps)
-* CLIENT_ID: Identificação de acesso. Sua geração ocorre no momento da criação pelo painel do desenvolvedor.
+* clientId: Identificação de acesso. Sua geração ocorre no momento da criação pelo painel do desenvolvedor.
Seu valor pode ser visualizado na coluna Client ID, dentro do menu
['Client ID Cadastrados'](https://desenvolvedores.cielo.com.br/api-portal/myapps)
diff --git a/android/app/build.gradle b/android/app/build.gradle
index fd75ae6..a475cad 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -1,67 +1,44 @@
-def localProperties = new Properties()
-def localPropertiesFile = rootProject.file('local.properties')
-if (localPropertiesFile.exists()) {
- localPropertiesFile.withReader('UTF-8') { reader ->
- localProperties.load(reader)
- }
-}
-
-def flutterRoot = localProperties.getProperty('flutter.sdk')
-if (flutterRoot == null) {
- throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
+plugins {
+ id "com.android.application"
+ id "kotlin-android"
+ // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
+ id "dev.flutter.flutter-gradle-plugin"
}
-def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
-if (flutterVersionCode == null) {
- flutterVersionCode = '1'
-}
-
-def flutterVersionName = localProperties.getProperty('flutter.versionName')
-if (flutterVersionName == null) {
- flutterVersionName = '1.0'
-}
-
-apply plugin: 'com.android.application'
-apply plugin: 'kotlin-android'
-apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
-
android {
- compileSdkVersion 28
+ namespace = "com.m4u.flutter_lio_integration"
+ compileSdk = flutter.compileSdkVersion
+ ndkVersion = flutter.ndkVersion
- sourceSets {
- main.java.srcDirs += 'src/main/kotlin'
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
}
- lintOptions {
- disable 'InvalidPackage'
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
- applicationId "com.m4u.flutter_lio_integration"
- minSdkVersion 16
- targetSdkVersion 28
- versionCode flutterVersionCode.toInteger()
- versionName flutterVersionName
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ applicationId = "com.m4u.flutter_lio_integration"
+ // You can update the following values to match your application needs.
+ // For more information, see: https://flutter.dev/to/review-gradle-config.
+ minSdk = flutter.minSdkVersion
+ targetSdk = flutter.targetSdkVersion
+ versionCode = flutter.versionCode
+ versionName = flutter.versionName
}
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 '../..'
-}
-
-dependencies {
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test:runner:1.1.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
-}
+ source = "../.."
+}
\ No newline at end of file
diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml
index 5f427a8..399f698 100644
--- a/android/app/src/debug/AndroidManifest.xml
+++ b/android/app/src/debug/AndroidManifest.xml
@@ -1,6 +1,6 @@
-
-
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index f1ddee3..4ee7ad1 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,12 +1,7 @@
-
+ android:windowSoftInputMode="adjustResize"
+ android:exported="true">
@@ -23,18 +19,11 @@
-
-
-
+
-
-
diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml
index 5f427a8..399f698 100644
--- a/android/app/src/profile/AndroidManifest.xml
+++ b/android/app/src/profile/AndroidManifest.xml
@@ -1,6 +1,6 @@
-
-
diff --git a/android/build.gradle b/android/build.gradle
index 3100ad2..d2ffbff 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,31 +1,18 @@
-buildscript {
- ext.kotlin_version = '1.3.50'
- repositories {
- google()
- jcenter()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:3.5.0'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
-}
-
allprojects {
repositories {
google()
- jcenter()
+ mavenCentral()
}
}
-rootProject.buildDir = '../build'
+rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
- project.evaluationDependsOn(':app')
+ project.evaluationDependsOn(":app")
}
-task clean(type: Delete) {
+tasks.register("clean", Delete) {
delete rootProject.buildDir
}
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index 296b146..7bb2df6 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
diff --git a/android/settings.gradle b/android/settings.gradle
index 5a2f14f..b9e43bd 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -1,15 +1,25 @@
-include ':app'
+pluginManagement {
+ def flutterSdkPath = {
+ def properties = new Properties()
+ file("local.properties").withInputStream { properties.load(it) }
+ def flutterSdkPath = properties.getProperty("flutter.sdk")
+ assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
+ return flutterSdkPath
+ }()
-def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
+ includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
-def plugins = new Properties()
-def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
-if (pluginsFile.exists()) {
- pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
}
-plugins.each { name, path ->
- def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
- include ":$name"
- project(":$name").projectDir = pluginDirectory
+plugins {
+ id "dev.flutter.flutter-plugin-loader" version "1.0.0"
+ id "com.android.application" version "8.1.0" apply false
+ id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}
+
+include ":app"
diff --git a/lib/auth/lio_deeplink_constants.dart b/lib/auth/lio_deeplink_constants.dart
new file mode 100644
index 0000000..0d150ec
--- /dev/null
+++ b/lib/auth/lio_deeplink_constants.dart
@@ -0,0 +1,4 @@
+abstract final class LioDeepLinkConstants {
+ static const accessToken = "";
+ static const clientId = "";
+}
diff --git a/lib/constants.dart b/lib/constants.dart
deleted file mode 100644
index e29d6e0..0000000
--- a/lib/constants.dart
+++ /dev/null
@@ -1,4 +0,0 @@
-class Constants {
- static const ACCESS_TOKEN = "";
- static const CLIENT_ID = "";
-}
diff --git a/lib/feature/payment_checkout/model/Payment_request.dart b/lib/feature/payment_checkout/model/Payment_request.dart
deleted file mode 100644
index f756cfb..0000000
--- a/lib/feature/payment_checkout/model/Payment_request.dart
+++ /dev/null
@@ -1,129 +0,0 @@
-import 'dart:convert';
-
-import 'package:flutter_lio_integration/constants.dart';
-import 'package:flutter_lio_integration/feature/payment_checkout/model/payment_type.dart';
-import 'package:flutter_lio_integration/feature/products/model/product.dart';
-
-class PaymentRequest {
- String accessToken;
- String clientId;
- dynamic email;
- int installments;
- List- items;
- String merchantCode;
- String paymentCode;
- int value;
-
- PaymentRequest({
- this.accessToken,
- this.clientId,
- this.email,
- this.installments,
- this.items,
- this.merchantCode,
- this.paymentCode,
- this.value,
- });
-
- factory PaymentRequest.fromJson(String str) =>
- PaymentRequest.fromMap(json.decode(str));
-
- String toJson() => json.encode(toMap());
-
- factory PaymentRequest.fromMap(Map json) => PaymentRequest(
- accessToken: json["accessToken"] == null ? null : json["accessToken"],
- clientId: json["clientID"] == null ? null : json["clientID"],
- email: json["email"],
- installments:
- json["installments"] == null ? null : json["installments"],
- items: json["items"] == null
- ? null
- : List
- .from(json["items"].map((x) => Item.fromMap(x))),
- merchantCode:
- json["merchantCode"] == null ? null : json["merchantCode"],
- paymentCode: json["paymentCode"] == null ? null : json["paymentCode"],
- value: json["value"] == null ? null : json["value"],
- );
-
- Map toMap() => {
- "accessToken": accessToken == null ? null : accessToken,
- "clientID": clientId == null ? null : clientId,
- "email": email,
- "installments": installments == null ? null : installments,
- "items": items == null
- ? null
- : List.from(items.map((x) => x.toMap())),
- "merchantCode": merchantCode == null ? null : merchantCode,
- "paymentCode": paymentCode == null ? null : paymentCode,
- "value": value == null ? null : value,
- };
-
- String toBase64Encode() => covertToBase64();
-
- covertToBase64() {
- List encodedText = utf8.encode(toJson());
- return base64.encode(encodedText);
- }
-
- static PaymentRequest makeOrder(PaymentType paymentType, Product product) {
- return PaymentRequest(
- accessToken: Constants.ACCESS_TOKEN,
- clientId: Constants.CLIENT_ID,
- email: "defina_email@gmail.com",
- installments: 0,
- merchantCode: "",
- paymentCode: paymentType == PaymentType.CREDITO_AVISTA
- ? "CREDITO_AVISTA"
- : "DEBITO_AVISTA",
- items: makeItem(product),
- value: product.unitPrice);
- }
-
- static List
- makeItem(Product product) {
- return [
- Item(
- name: product.name,
- quantity: product.quantity,
- sku: product.sku,
- unitOfMeasure: product.unitOfMeasure,
- unitPrice: product.unitPrice)
- ];
- }
-}
-
-class Item {
- String name;
- int quantity;
- String sku;
- String unitOfMeasure;
- int unitPrice;
-
- Item({
- this.name,
- this.quantity,
- this.sku,
- this.unitOfMeasure,
- this.unitPrice,
- });
-
- factory Item.fromJson(String str) => Item.fromMap(json.decode(str));
-
- String toJson() => json.encode(toMap());
-
- factory Item.fromMap(Map json) => Item(
- name: json["name"] == null ? null : json["name"],
- quantity: json["quantity"] == null ? null : json["quantity"],
- sku: json["sku"] == null ? null : json["sku"],
- unitOfMeasure:
- json["unitOfMeasure"] == null ? null : json["unitOfMeasure"],
- unitPrice: json["unitPrice"] == null ? null : json["unitPrice"],
- );
-
- Map toMap() => {
- "name": name == null ? null : name,
- "quantity": quantity == null ? null : quantity,
- "sku": sku == null ? null : sku,
- "unitOfMeasure": unitOfMeasure == null ? null : unitOfMeasure,
- "unitPrice": unitPrice == null ? null : unitPrice,
- };
-}
diff --git a/lib/feature/payment_checkout/model/payment_response.dart b/lib/feature/payment_checkout/model/payment_response.dart
deleted file mode 100644
index e7f2d59..0000000
--- a/lib/feature/payment_checkout/model/payment_response.dart
+++ /dev/null
@@ -1,30 +0,0 @@
-import 'dart:convert';
-import 'order.dart';
-
-class PaymentCheckoutResponse {
- int code;
- Order order;
- String reason;
-
- PaymentCheckoutResponse({
- this.code,
- this.order,
- this.reason,
- });
-
- factory PaymentCheckoutResponse.fromJson(String str) => PaymentCheckoutResponse.fromMap(json.decode(str));
-
- String toJson() => json.encode(toMap());
-
- factory PaymentCheckoutResponse.fromMap(Map json) => PaymentCheckoutResponse(
- code: json["code"] == null ? null : json["code"],
- order: Order.fromMap(json["order"]),
- reason: json["reason"] == null ? null : json["reason"],
- );
-
- Map toMap() => {
- "code": code == null ? null : code,
- "order": order.toMap(),
- "reason": reason == null ? null : reason,
- };
-}
\ No newline at end of file
diff --git a/lib/feature/payment_checkout/model/payment_response_success.dart b/lib/feature/payment_checkout/model/payment_response_success.dart
deleted file mode 100644
index 45d8448..0000000
--- a/lib/feature/payment_checkout/model/payment_response_success.dart
+++ /dev/null
@@ -1,136 +0,0 @@
-import 'dart:convert';
-
-import 'package:flutter_lio_integration/feature/payment_checkout/model/payment.dart';
-
-class PaymentCheckoutResponseSuccess {
- String createdAt;
- String id;
- List
- items;
- String notes;
- String number;
- int paidAmount;
- List payments;
- int pendingAmount;
- int price;
- String reference;
- String status;
- String type;
- String updatedAt;
-
- PaymentCheckoutResponseSuccess({
- this.createdAt,
- this.id,
- this.items,
- this.notes,
- this.number,
- this.paidAmount,
- this.payments,
- this.pendingAmount,
- this.price,
- this.reference,
- this.status,
- this.type,
- this.updatedAt,
- });
-
- factory PaymentCheckoutResponseSuccess.fromJson(String str) =>
- PaymentCheckoutResponseSuccess.fromMap(json.decode(str));
-
- String toJson() => json.encode(toMap());
-
- factory PaymentCheckoutResponseSuccess.fromMap(Map json) =>
- PaymentCheckoutResponseSuccess(
- createdAt: json["createdAt"] == null ? null : json["createdAt"],
- id: json["id"] == null ? null : json["id"],
- items: json["items"] == null
- ? null
- : List
- .from(json["items"].map((x) => Item.fromMap(x))),
- notes: json["notes"] == null ? null : json["notes"],
- number: json["number"] == null ? null : json["number"],
- paidAmount: json["paidAmount"] == null ? null : json["paidAmount"],
- payments: json["payments"] == null
- ? null
- : List.from(
- json["payments"].map((x) => Payment.fromMap(x))),
- pendingAmount:
- json["pendingAmount"] == null ? null : json["pendingAmount"],
- price: json["price"] == null ? null : json["price"],
- reference: json["reference"] == null ? null : json["reference"],
- status: json["status"] == null ? null : json["status"],
- type: json["type"] == null ? null : json["type"],
- updatedAt: json["updatedAt"] == null ? null : json["updatedAt"],
- );
-
- Map toMap() => {
- "createdAt": createdAt == null ? null : createdAt,
- "id": id == null ? null : id,
- "items": items == null
- ? null
- : List.from(items.map((x) => x.toMap())),
- "notes": notes == null ? null : notes,
- "number": number == null ? null : number,
- "paidAmount": paidAmount == null ? null : paidAmount,
- "payments": payments == null
- ? null
- : List.from(payments.map((x) => x.toMap())),
- "pendingAmount": pendingAmount == null ? null : pendingAmount,
- "price": price == null ? null : price,
- "reference": reference == null ? null : reference,
- "status": status == null ? null : status,
- "type": type == null ? null : type,
- "updatedAt": updatedAt == null ? null : updatedAt,
- };
-}
-
-class Item {
- String description;
- String details;
- String id;
- String name;
- int quantity;
- String reference;
- String sku;
- String unitOfMeasure;
- int unitPrice;
-
- Item({
- this.description,
- this.details,
- this.id,
- this.name,
- this.quantity,
- this.reference,
- this.sku,
- this.unitOfMeasure,
- this.unitPrice,
- });
-
- factory Item.fromJson(String str) => Item.fromMap(json.decode(str));
-
- String toJson() => json.encode(toMap());
-
- factory Item.fromMap(Map json) => Item(
- description: json["description"] == null ? null : json["description"],
- details: json["details"] == null ? null : json["details"],
- id: json["id"] == null ? null : json["id"],
- name: json["name"] == null ? null : json["name"],
- quantity: json["quantity"] == null ? null : json["quantity"],
- reference: json["reference"] == null ? null : json["reference"],
- sku: json["sku"] == null ? null : json["sku"],
- unitOfMeasure:
- json["unitOfMeasure"] == null ? null : json["unitOfMeasure"],
- unitPrice: json["unitPrice"] == null ? null : json["unitPrice"],
- );
-
- Map toMap() => {
- "description": description == null ? null : description,
- "details": details == null ? null : details,
- "id": id == null ? null : id,
- "name": name == null ? null : name,
- "quantity": quantity == null ? null : quantity,
- "reference": reference == null ? null : reference,
- "sku": sku == null ? null : sku,
- "unitOfMeasure": unitOfMeasure == null ? null : unitOfMeasure,
- "unitPrice": unitPrice == null ? null : unitPrice,
- };
-}
diff --git a/lib/feature/payment_checkout/model/payment_type.dart b/lib/feature/payment_checkout/model/payment_type.dart
deleted file mode 100644
index a1f6f39..0000000
--- a/lib/feature/payment_checkout/model/payment_type.dart
+++ /dev/null
@@ -1 +0,0 @@
-enum PaymentType { CREDITO_AVISTA, DEBITO_AVISTA }
diff --git a/lib/feature/payment_checkout/payment_checkout_presenter.dart b/lib/feature/payment_checkout/payment_checkout_presenter.dart
deleted file mode 100644
index 0357ff2..0000000
--- a/lib/feature/payment_checkout/payment_checkout_presenter.dart
+++ /dev/null
@@ -1,69 +0,0 @@
-import 'dart:convert';
-
-import 'package:flutter/services.dart' show PlatformException;
-import 'package:flutter_lio_integration/feature/payment_checkout/model/Payment_request.dart';
-import 'package:flutter_lio_integration/feature/payment_checkout/model/payment_type.dart';
-import 'package:flutter_lio_integration/feature/payment_checkout/payment_checkout_view.dart';
-import 'package:flutter_lio_integration/feature/products/model/product.dart';
-import 'package:uni_links/uni_links.dart';
-import 'package:url_launcher/url_launcher.dart';
-
-import 'model/payment_response.dart';
-import 'model/payment_response_success.dart';
-
-class PaymentCheckoutPresenter {
- PaymentCheckoutView _view;
- final Product product;
-
- PaymentCheckoutPresenter(this.product);
-
- setView(PaymentCheckoutView view) {
- this._view = view;
- }
-
- Future checkout(PaymentType paymentType, Product product) async {
- var payment = PaymentRequest.makeOrder(paymentType, product);
-
- var url = "lio://payment?request=" +
- payment.toBase64Encode() +
- "&urlCallback=order://payment";
- if (await canLaunch(url)) {
- await launch(url);
- } else {
- _view.showMessage('Erro: App URI não instalado.');
- }
- }
-
- void onFailure(PaymentCheckoutResponse response) {
- _view.showMessage(response.toJson());
- }
-
- void onSuccess(PaymentCheckoutResponseSuccess response) {
- _view.showMessage(response.toJson());
- }
-
- Future startListener() async {
- try {
- await getInitialLink();
- } on PlatformException {
- print("error");
- }
-
- getUriLinksStream().listen((Uri uri) {
- String response = uri.queryParameters["response"];
- if (response.isNotEmpty) {
- String response = uri.queryParameters["response"];
- var coverted =
- String.fromCharCodes(base64Decode(response.replaceAll("\n", "")));
- print(coverted);
- if (uri.queryParameters["responsecode"] != null) {
- onSuccess(PaymentCheckoutResponseSuccess.fromJson(coverted));
- } else {
- onFailure(PaymentCheckoutResponse.fromJson(coverted));
- }
- }
- }, onError: (err) {
- print(err.toString());
- });
- }
-}
diff --git a/lib/features/payment_checkout/model/Payment_request.dart b/lib/features/payment_checkout/model/Payment_request.dart
new file mode 100644
index 0000000..a0dc7e6
--- /dev/null
+++ b/lib/features/payment_checkout/model/Payment_request.dart
@@ -0,0 +1,120 @@
+import 'dart:convert';
+import 'package:flutter_lio_integration/auth/lio_deeplink_constants.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/model/payment_type.dart';
+import 'package:flutter_lio_integration/features/products/model/product.dart';
+
+class PaymentRequest {
+ String? accessToken;
+ String? clientId;
+ dynamic email;
+ int? installments;
+ List
- ? items;
+ String? merchantCode;
+ String? paymentCode;
+ int? value;
+
+ PaymentRequest({
+ this.accessToken,
+ this.clientId,
+ this.email,
+ this.installments,
+ this.items,
+ this.merchantCode,
+ this.paymentCode,
+ this.value,
+ });
+
+ factory PaymentRequest.fromJson(String str) =>
+ PaymentRequest.fromMap(json.decode(str));
+
+ String toJson() => json.encode(toMap());
+
+ factory PaymentRequest.fromMap(Map json) => PaymentRequest(
+ accessToken: json["accessToken"],
+ clientId: json["clientID"],
+ email: json["email"],
+ installments: json["installments"],
+ merchantCode: json["merchantCode"],
+ paymentCode: json["paymentCode"],
+ value: json["value"],
+ items: json["items"] != null
+ ? List
- .from(json["items"].map((x) => Item.fromMap(x)))
+ : null,
+ );
+
+ Map toMap() => {
+ "accessToken": accessToken,
+ "clientID": clientId,
+ "email": email,
+ "installments": installments,
+ "merchantCode": merchantCode,
+ "paymentCode": paymentCode,
+ "value": value,
+ "items": items != null
+ ? List.from(items!.map((x) => x.toMap()))
+ : null,
+ };
+
+ String toBase64Encode() => base64Encode(utf8.encode(toJson()));
+
+ static PaymentRequest makeOrder(PaymentType paymentType, Product product) {
+ return PaymentRequest(
+ accessToken: LioDeepLinkConstants.accessToken,
+ clientId: LioDeepLinkConstants.clientId,
+ email: "defina_email@gmail.com",
+ installments: 0,
+ merchantCode: "",
+ paymentCode: paymentType == PaymentType.creditoAVista
+ ? "creditoAVista"
+ : "debitoAVista",
+ items: makeItem(product),
+ value: product.unitPrice);
+ }
+
+ static List
- makeItem(Product product) {
+ return [
+ Item(
+ name: product.name,
+ quantity: product.quantity,
+ sku: product.sku,
+ unitOfMeasure: product.unitOfMeasure,
+ unitPrice: product.unitPrice)
+ ];
+ }
+}
+
+class Item {
+ String? name;
+ int? quantity;
+ String? sku;
+ String? unitOfMeasure;
+ int? unitPrice;
+
+ Item({
+ this.name,
+ this.quantity,
+ this.sku,
+ this.unitOfMeasure,
+ this.unitPrice,
+ });
+
+ factory Item.fromJson(String str) => Item.fromMap(json.decode(str));
+
+ String toJson() => json.encode(toMap());
+
+ factory Item.fromMap(Map json) => Item(
+ name: json["name"],
+ quantity: json["quantity"],
+ sku: json["sku"],
+ unitOfMeasure: json["unitOfMeasure"],
+ unitPrice: json["unitPrice"],
+ );
+
+ Map toMap() => {
+ "name": name == null ? null : name,
+ "quantity": quantity == null ? null : quantity,
+ "sku": sku == null ? null : sku,
+ "unitOfMeasure": unitOfMeasure == null ? null : unitOfMeasure,
+ "unitPrice": unitPrice == null ? null : unitPrice,
+ };
+}
diff --git a/lib/feature/payment_checkout/model/order.dart b/lib/features/payment_checkout/model/order.dart
similarity index 58%
rename from lib/feature/payment_checkout/model/order.dart
rename to lib/features/payment_checkout/model/order.dart
index 0c54911..eff859a 100644
--- a/lib/feature/payment_checkout/model/order.dart
+++ b/lib/features/payment_checkout/model/order.dart
@@ -1,20 +1,20 @@
-import 'package:flutter_lio_integration/feature/payment_checkout/model/Payment_request.dart';
-import 'package:flutter_lio_integration/feature/payment_checkout/model/payment.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/model/Payment_request.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/model/payment.dart';
class Order {
- String createdAt;
- String id;
- List
- items;
- String notes;
- String number;
- int paidAmount;
- List payments;
- int pendingAmount;
- int price;
- String reference;
- String status;
- String type;
- String updatedAt;
+ String? createdAt;
+ String? id;
+ List
- ? items;
+ String? notes;
+ String? number;
+ int? paidAmount;
+ List? payments;
+ int? pendingAmount;
+ int? price;
+ String? reference;
+ String? status;
+ String? type;
+ String? updatedAt;
Order({
this.createdAt,
@@ -39,8 +39,11 @@ class Order {
notes: json["notes"],
number: json["number"],
paidAmount: json["paidAmount"],
- payments:
- List.from(json["payments"].map((x) => Payment.fromMap(x))),
+ payments: List.from(
+ json["payments"].map(
+ (x) => Payment.fromMap(x),
+ ),
+ ),
pendingAmount: json["pendingAmount"],
price: json["price"],
reference: json["reference"],
@@ -52,16 +55,20 @@ class Order {
Map toMap() => {
"createdAt": createdAt,
"id": id,
- "items": List.from(items.map((x) => x.toMap())),
"notes": notes,
"number": number,
"paidAmount": paidAmount,
- "payments": List.from(payments.map((x) => x.toMap())),
"pendingAmount": pendingAmount,
"price": price,
"reference": reference,
"status": status,
"type": type,
"updatedAt": updatedAt,
+ "items": (items != null)
+ ? List.from(items!.map((x) => x.toMap()))
+ : null,
+ "payments": (payments != null)
+ ? List.from(payments!.map((x) => x.toMap()))
+ : null,
};
}
diff --git a/lib/feature/payment_checkout/model/payment.dart b/lib/features/payment_checkout/model/payment.dart
similarity index 74%
rename from lib/feature/payment_checkout/model/payment.dart
rename to lib/features/payment_checkout/model/payment.dart
index 3a27123..98a55bf 100644
--- a/lib/feature/payment_checkout/model/payment.dart
+++ b/lib/features/payment_checkout/model/payment.dart
@@ -1,26 +1,26 @@
import 'dart:convert';
-import 'package:flutter_lio_integration/feature/payment_checkout/model/payment_fields.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/model/payment_fields.dart';
class Payment {
- String accessKey;
- int amount;
- String applicationName;
- String authCode;
- String brand;
- String cieloCode;
- String description;
- int discountedAmount;
- String externalId;
- String id;
- int installments;
- String mask;
- String merchantCode;
- PaymentFields paymentFields;
- String primaryCode;
- String requestDate;
- String secondaryCode;
- String terminal;
+ String? accessKey;
+ int? amount;
+ String? applicationName;
+ String? authCode;
+ String? brand;
+ String? cieloCode;
+ String? description;
+ int? discountedAmount;
+ String? externalId;
+ String? id;
+ int? installments;
+ String? mask;
+ String? merchantCode;
+ PaymentFields? paymentFields;
+ String? primaryCode;
+ String? requestDate;
+ String? secondaryCode;
+ String? terminal;
Payment({
this.accessKey,
@@ -82,17 +82,12 @@ class Payment {
"installments": installments,
"mask": mask,
"merchantCode": merchantCode,
- "paymentFields": paymentFields.toMap(),
+ "paymentFields": (paymentFields != null) ? paymentFields!.toMap() : {},
"primaryCode": primaryCode,
"requestDate": requestDate,
"secondaryCode": secondaryCode,
"terminal": terminal,
};
- String toBase64Encode() => covertToBase64();
-
- covertToBase64() {
- List encodedText = utf8.encode(toJson());
- return base64.encode(encodedText);
- }
+ String toBase64Encode() => base64Encode(utf8.encode(toJson()));
}
diff --git a/lib/feature/payment_checkout/model/payment_fields.dart b/lib/features/payment_checkout/model/payment_fields.dart
similarity index 82%
rename from lib/feature/payment_checkout/model/payment_fields.dart
rename to lib/features/payment_checkout/model/payment_fields.dart
index 13a6591..b9eb077 100644
--- a/lib/feature/payment_checkout/model/payment_fields.dart
+++ b/lib/features/payment_checkout/model/payment_fields.dart
@@ -1,50 +1,50 @@
class PaymentFields {
- String cityState;
- String serviceTax;
- String documentType;
- String hasConnectivity;
- String document;
- String entranceMode;
- String paymentTypeCode;
- String hasPassword;
- String changeAmount;
- String productName;
- String hasWarranty;
- String merchantName;
- String hasSentMerchantCode;
- String isOnlyIntegrationCancelable;
- String primaryProductCode;
- String originalTransactionId;
- String requestDate;
- String firstQuotaAmount;
- String secondaryProductCode;
- String pan;
- String applicationName;
- String isFinancialProduct;
- String v40Code;
- String merchantCode;
- String totalizerCode;
- String isDoubleFontPrintAllowed;
- String hasSentReference;
- String isExternalCall;
- String originalTransactionDate;
- String interestAmount;
- String receiptPrintPermission;
- String cardCaptureType;
- String upFrontAmount;
- String hasPrintedClientReceipt;
- String creditAdminTax;
- String primaryProductName;
- String avaiableBalance;
- String merchantAddress;
- String applicationId;
- String numberOfQuotas;
- String boardingTax;
- String paymentTransactionId;
- String firstQuotaDate;
- String hasSignature;
- String secondaryProductName;
- String statusCode;
+ String? cityState;
+ String? serviceTax;
+ String? documentType;
+ String? hasConnectivity;
+ String? document;
+ String? entranceMode;
+ String? paymentTypeCode;
+ String? hasPassword;
+ String? changeAmount;
+ String? productName;
+ String? hasWarranty;
+ String? merchantName;
+ String? hasSentMerchantCode;
+ String? isOnlyIntegrationCancelable;
+ String? primaryProductCode;
+ String? originalTransactionId;
+ String? requestDate;
+ String? firstQuotaAmount;
+ String? secondaryProductCode;
+ String? pan;
+ String? applicationName;
+ String? isFinancialProduct;
+ String? v40Code;
+ String? merchantCode;
+ String? totalizerCode;
+ String? isDoubleFontPrintAllowed;
+ String? hasSentReference;
+ String? isExternalCall;
+ String? originalTransactionDate;
+ String? interestAmount;
+ String? receiptPrintPermission;
+ String? cardCaptureType;
+ String? upFrontAmount;
+ String? hasPrintedClientReceipt;
+ String? creditAdminTax;
+ String? primaryProductName;
+ String? avaiableBalance;
+ String? merchantAddress;
+ String? applicationId;
+ String? numberOfQuotas;
+ String? boardingTax;
+ String? paymentTransactionId;
+ String? firstQuotaDate;
+ String? hasSignature;
+ String? secondaryProductName;
+ String? statusCode;
PaymentFields({
this.cityState,
diff --git a/lib/features/payment_checkout/model/payment_response.dart b/lib/features/payment_checkout/model/payment_response.dart
new file mode 100644
index 0000000..f8a44eb
--- /dev/null
+++ b/lib/features/payment_checkout/model/payment_response.dart
@@ -0,0 +1,32 @@
+import 'dart:convert';
+import 'order.dart';
+
+class PaymentCheckoutResponse {
+ int? code;
+ Order? order;
+ String? reason;
+
+ PaymentCheckoutResponse({
+ this.code,
+ this.order,
+ this.reason,
+ });
+
+ factory PaymentCheckoutResponse.fromJson(String str) =>
+ PaymentCheckoutResponse.fromMap(json.decode(str));
+
+ String toJson() => json.encode(toMap());
+
+ factory PaymentCheckoutResponse.fromMap(Map json) =>
+ PaymentCheckoutResponse(
+ code: json["code"],
+ order: (json["order"] != null) ? Order.fromMap(json["order"]) : null,
+ reason: json["reason"],
+ );
+
+ Map toMap() => {
+ "code": code == null ? null : code,
+ "order": (order != null) ? order!.toMap() : {},
+ "reason": reason == null ? null : reason,
+ };
+}
diff --git a/lib/features/payment_checkout/model/payment_response_success.dart b/lib/features/payment_checkout/model/payment_response_success.dart
new file mode 100644
index 0000000..62e9981
--- /dev/null
+++ b/lib/features/payment_checkout/model/payment_response_success.dart
@@ -0,0 +1,135 @@
+import 'dart:convert';
+import 'package:flutter_lio_integration/features/payment_checkout/model/payment.dart';
+
+
+class PaymentCheckoutResponseSuccess {
+ String? createdAt;
+ String? id;
+ List
- ? items;
+ String? notes;
+ String? number;
+ int? paidAmount;
+ List? payments;
+ int? pendingAmount;
+ int? price;
+ String? reference;
+ String? status;
+ String? type;
+ String? updatedAt;
+
+ PaymentCheckoutResponseSuccess({
+ this.createdAt,
+ this.id,
+ this.items,
+ this.notes,
+ this.number,
+ this.paidAmount,
+ this.payments,
+ this.pendingAmount,
+ this.price,
+ this.reference,
+ this.status,
+ this.type,
+ this.updatedAt,
+ });
+
+ factory PaymentCheckoutResponseSuccess.fromJson(String str) =>
+ PaymentCheckoutResponseSuccess.fromMap(json.decode(str));
+
+ String toJson() => json.encode(toMap());
+
+ factory PaymentCheckoutResponseSuccess.fromMap(Map json) =>
+ PaymentCheckoutResponseSuccess(
+ createdAt: json["createdAt"],
+ id: json["id"],
+ items: json["items"] != null
+ ? List
- .from(json["items"].map((x) => Item.fromMap(x!)))
+ : null,
+ notes: json["notes"],
+ number: json["number"],
+ paidAmount: json["paidAmount"],
+ payments: json["payments"] == null
+ ? null
+ : List.from(
+ json["payments"].map((x) => Payment.fromMap(x))),
+ pendingAmount:
+ json["pendingAmount"],
+ price: json["price"],
+ reference: json["reference"],
+ status: json["status"],
+ type: json["type"],
+ updatedAt: json["updatedAt"],
+ );
+
+ Map toMap() => {
+ "createdAt": createdAt == null ? null : createdAt,
+ "id": id == null ? null : id,
+ "items": items != null
+ ? List.from(items!.map((x) => x.toMap()))
+ : null,
+ "notes": notes == null ? null : notes,
+ "number": number == null ? null : number,
+ "paidAmount": paidAmount == null ? null : paidAmount,
+ "payments": payments != null
+ ? List.from(payments!.map((x) => x.toMap()))
+ : null,
+ "pendingAmount": pendingAmount == null ? null : pendingAmount,
+ "price": price == null ? null : price,
+ "reference": reference == null ? null : reference,
+ "status": status == null ? null : status,
+ "type": type == null ? null : type,
+ "updatedAt": updatedAt == null ? null : updatedAt,
+ };
+}
+class Item {
+ String ?description;
+ String ?details;
+ String ?id;
+ String ?name;
+ int ?quantity;
+ String ?reference;
+ String ?sku;
+ String ?unitOfMeasure;
+ int ?unitPrice;
+
+ Item({
+ this.description,
+ this.details,
+ this.id,
+ this.name,
+ this.quantity,
+ this.reference,
+ this.sku,
+ this.unitOfMeasure,
+ this.unitPrice,
+ });
+
+ factory Item.fromJson(String str) => Item.fromMap(json.decode(str));
+
+ String toJson() => json.encode(toMap());
+
+ factory Item.fromMap(Map json) => Item(
+ description: json["description"],
+ details: json["details"],
+ id: json["id"],
+ name: json["name"],
+ quantity: json["quantity"],
+ reference: json["reference"],
+ sku: json["sku"],
+ unitOfMeasure:
+ json["unitOfMeasure"],
+ unitPrice: json["unitPrice"],
+ );
+
+ Map toMap() => {
+ "description": description,
+ "details": details,
+ "id": id,
+ "name": name,
+ "quantity": quantity,
+ "reference": reference,
+ "sku": sku,
+ "unitOfMeasure": unitOfMeasure,
+ "unitPrice": unitPrice,
+ };
+}
\ No newline at end of file
diff --git a/lib/features/payment_checkout/model/payment_type.dart b/lib/features/payment_checkout/model/payment_type.dart
new file mode 100644
index 0000000..2ed75bc
--- /dev/null
+++ b/lib/features/payment_checkout/model/payment_type.dart
@@ -0,0 +1,4 @@
+enum PaymentType {
+ creditoAVista,
+ debitoAVista,
+}
diff --git a/lib/features/payment_checkout/payment_checkout_presenter.dart b/lib/features/payment_checkout/payment_checkout_presenter.dart
new file mode 100644
index 0000000..3fd9cdc
--- /dev/null
+++ b/lib/features/payment_checkout/payment_checkout_presenter.dart
@@ -0,0 +1,78 @@
+import 'dart:convert';
+import 'package:app_links/app_links.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/model/Payment_request.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/model/payment_type.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/payment_checkout_view.dart';
+import 'package:flutter_lio_integration/features/products/model/product.dart';
+import 'package:url_launcher/url_launcher.dart';
+import 'model/payment_response.dart';
+import 'model/payment_response_success.dart';
+
+class PaymentCheckoutPresenter {
+ PaymentCheckoutView view;
+ final Product product;
+
+ PaymentCheckoutPresenter(this.product) : view = PaymentCheckoutView();
+
+ Future checkout(PaymentType paymentType, Product product) async {
+ final payment = PaymentRequest.makeOrder(paymentType, product);
+
+ final uri = Uri.parse(
+ "lio://payment?request=${payment.toBase64Encode()}&urlCallback=order://payment",
+ );
+
+ if (await canLaunchUrl(uri)) {
+ await launchUrl(uri);
+ return;
+ }
+ view.showMessage('Erro: App URI não instalado.');
+ }
+
+ void onFailure(PaymentCheckoutResponse response) {
+ view.showMessage(response.toJson());
+ }
+
+ void onSuccess(PaymentCheckoutResponseSuccess response) {
+ view.showMessage(response.toJson());
+ }
+
+ final AppLinks _appLinks = AppLinks();
+
+ Future startListener() async {
+ try {
+ final Uri? initialUri = await _appLinks.getInitialLink();
+ if (initialUri != null) {
+ handleUri(initialUri);
+ }
+ } catch (e) {
+ print("Erro ao obter o link inicial: $e");
+ }
+
+ _appLinks.uriLinkStream.listen(
+ (Uri uri) {
+ handleUri(uri);
+ },
+ onError: (err) {
+ print("Erro ao escutar links: ${err.toString()}");
+ },
+ );
+ }
+
+ void handleUri(Uri uri) {
+ String response = uri.queryParameters["response"] ?? '';
+ if (response.isNotEmpty) {
+ final converted = String.fromCharCodes(
+ base64Decode(
+ response.replaceAll("\n", ""),
+ ),
+ );
+
+ print(converted);
+ if (uri.queryParameters["responsecode"] != null) {
+ onSuccess(PaymentCheckoutResponseSuccess.fromJson(converted));
+ return;
+ }
+ onFailure(PaymentCheckoutResponse.fromJson(converted));
+ }
+ }
+}
diff --git a/lib/feature/payment_checkout/payment_checkout_screen.dart b/lib/features/payment_checkout/payment_checkout_screen.dart
similarity index 56%
rename from lib/feature/payment_checkout/payment_checkout_screen.dart
rename to lib/features/payment_checkout/payment_checkout_screen.dart
index dc9a7d8..47ded93 100644
--- a/lib/feature/payment_checkout/payment_checkout_screen.dart
+++ b/lib/features/payment_checkout/payment_checkout_screen.dart
@@ -1,28 +1,27 @@
import 'package:flutter/material.dart';
-import 'package:flutter_lio_integration/feature/payment_checkout/model/payment_type.dart';
-import 'package:flutter_lio_integration/feature/payment_checkout/payment_checkout_presenter.dart';
-import 'package:flutter_lio_integration/feature/payment_checkout/payment_checkout_view.dart';
-import 'package:flutter_lio_integration/feature/products/model/product.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/model/payment_type.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/payment_checkout_presenter.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/payment_checkout_view.dart';
+import 'package:flutter_lio_integration/features/products/model/product.dart';
class PaymentCheckoutScreen extends StatefulWidget {
final Product product;
- const PaymentCheckoutScreen({Key key, this.product}) : super(key: key);
+ const PaymentCheckoutScreen({super.key, required this.product});
@override
- _PaymentCheckoutScreenState createState() => _PaymentCheckoutScreenState();
+ State createState() => _PaymentCheckoutScreenState();
}
class _PaymentCheckoutScreenState extends State
implements PaymentCheckoutView {
- PaymentCheckoutPresenter presenter;
+ late PaymentCheckoutPresenter presenter;
String message = "";
@override
void initState() {
super.initState();
presenter = PaymentCheckoutPresenter(this.widget.product);
- presenter.setView(this);
presenter.startListener();
}
@@ -30,16 +29,17 @@ class _PaymentCheckoutScreenState extends State
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
- title: Text("Flutter-LIO"),
+ title: Text("Checkout de Venda"),
),
body: Container(
+ alignment: Alignment.center,
child: Column(
children: [
SizedBox(
height: 20,
),
Text(
- widget.product.name,
+ widget.product.name ?? '',
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
SizedBox(
@@ -49,7 +49,7 @@ class _PaymentCheckoutScreenState extends State
SizedBox(
height: 10,
),
- Text("Preço: R\$ ${widget.product.unitPrice.roundToDouble()}"),
+ Text("Preço: R\$ ${widget.product.unitPrice?.roundToDouble()}"),
SizedBox(
height: 10,
),
@@ -58,12 +58,13 @@ class _PaymentCheckoutScreenState extends State
child: ButtonTheme(
height: 50.0,
minWidth: MediaQuery.of(context).size.width,
- child: RaisedButton(
- color: Theme.of(context).accentColor,
- textColor: Colors.white,
- elevation: 4.0,
- shape: RoundedRectangleBorder(
- borderRadius: new BorderRadius.circular(50.0),
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Theme.of(context).colorScheme.tertiary,
+ elevation: 4.0,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(50.0),
+ ),
),
child: Text(
"Crédito Avista",
@@ -71,7 +72,7 @@ class _PaymentCheckoutScreenState extends State
),
onPressed: () {
presenter.checkout(
- PaymentType.CREDITO_AVISTA, widget.product);
+ PaymentType.creditoAVista, widget.product);
},
),
),
@@ -81,12 +82,13 @@ class _PaymentCheckoutScreenState extends State
child: ButtonTheme(
height: 50.0,
minWidth: MediaQuery.of(context).size.width,
- child: RaisedButton(
- color: Theme.of(context).accentColor,
- textColor: Colors.white,
- elevation: 4.0,
- shape: RoundedRectangleBorder(
- borderRadius: new BorderRadius.circular(50.0),
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Theme.of(context).colorScheme.tertiary,
+ elevation: 4.0,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(50.0),
+ ),
),
child: Text(
"Débito Avista",
@@ -94,7 +96,9 @@ class _PaymentCheckoutScreenState extends State
),
onPressed: () {
presenter.checkout(
- PaymentType.DEBITO_AVISTA, widget.product);
+ PaymentType.debitoAVista,
+ widget.product,
+ );
},
),
),
@@ -106,10 +110,10 @@ class _PaymentCheckoutScreenState extends State
flex: 1,
child: SingleChildScrollView(
child: Text(
- message,
- style: TextStyle(fontSize: 16.0),
- textAlign: TextAlign.center,
- )),
+ message,
+ style: TextStyle(fontSize: 16.0),
+ textAlign: TextAlign.center,
+ )),
),
],
),
@@ -119,8 +123,7 @@ class _PaymentCheckoutScreenState extends State
@override
void showMessage(String message) {
- setState(() {
- this.message = message;
- });
+ this.message = message;
+ setState(() {});
}
}
diff --git a/lib/feature/payment_checkout/payment_checkout_view.dart b/lib/features/payment_checkout/payment_checkout_view.dart
similarity index 100%
rename from lib/feature/payment_checkout/payment_checkout_view.dart
rename to lib/features/payment_checkout/payment_checkout_view.dart
diff --git a/lib/feature/products/model/product.dart b/lib/features/products/model/product.dart
similarity index 69%
rename from lib/feature/products/model/product.dart
rename to lib/features/products/model/product.dart
index e2e0a18..83e2210 100644
--- a/lib/feature/products/model/product.dart
+++ b/lib/features/products/model/product.dart
@@ -1,12 +1,17 @@
class Product {
- final String name;
- final int quantity;
- final String sku;
- final String unitOfMeasure;
- final int unitPrice;
+ final String? name;
+ final int? quantity;
+ final String? sku;
+ final String? unitOfMeasure;
+ final int? unitPrice;
- Product(
- {this.name, this.quantity, this.sku, this.unitOfMeasure, this.unitPrice});
+ Product({
+ this.name,
+ this.quantity,
+ this.sku,
+ this.unitOfMeasure,
+ this.unitPrice,
+ });
static List list() {
return [
diff --git a/lib/feature/products/product_list.dart b/lib/features/products/product_list.dart
similarity index 75%
rename from lib/feature/products/product_list.dart
rename to lib/features/products/product_list.dart
index 4ff5dc4..f10b43c 100644
--- a/lib/feature/products/product_list.dart
+++ b/lib/features/products/product_list.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
-import 'package:flutter_lio_integration/feature/products/model/product.dart';
-import 'package:flutter_lio_integration/routes.dart';
+import 'package:flutter_lio_integration/features/products/model/product.dart';
+import 'package:flutter_lio_integration/routing/routes.dart';
+import 'package:go_router/go_router.dart';
class ProductList extends StatefulWidget {
@override
@@ -21,14 +22,14 @@ class _ProductListState extends State {
itemBuilder: ((context, index) {
return ListTile(
title: Text(
- items[index].name,
+ items[index].name ?? '',
style: TextStyle(
color: Colors.blue,
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
onTap: () {
- Navigator.pushNamed(context, checkout, arguments: items[index]);
+ context.go(Routes.checkout, extra: items[index]);
},
);
}),
diff --git a/lib/main.dart b/lib/main.dart
index 7e6b55a..d6dc152 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,17 +1,18 @@
import 'package:flutter/material.dart';
-import 'package:flutter_lio_integration/routes.dart';
+import 'package:flutter_lio_integration/routing/router.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return MaterialApp(
- title: 'SDK Intergration',
- theme: ThemeData(
+ return MaterialApp.router(
+ title: 'SDK Integration',
+ routerConfig: router,
+ debugShowCheckedModeBanner: false,
+ theme: ThemeData(
primarySwatch: Colors.blue,
),
- onGenerateRoute: Router.generateRoute,
);
}
}
diff --git a/lib/routes.dart b/lib/routes.dart
deleted file mode 100644
index 7ede450..0000000
--- a/lib/routes.dart
+++ /dev/null
@@ -1,24 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter_lio_integration/feature/payment_checkout/payment_checkout_screen.dart';
-import 'package:flutter_lio_integration/feature/products/product_list.dart';
-
-const String rootRoute = "/";
-const String checkout = "/checkout";
-
-class Router {
- static Route generateRoute(RouteSettings settings) {
- switch (settings.name) {
- case rootRoute:
- return MaterialPageRoute(builder: (_) => ProductList());
- case checkout:
- return MaterialPageRoute(
- builder: (_) => PaymentCheckoutScreen(product: settings.arguments));
- default:
- return MaterialPageRoute(
- builder: (_) => Scaffold(
- body: Center(
- child: Text('No route defined for ${settings.name}')),
- ));
- }
- }
-}
diff --git a/lib/routing/router.dart b/lib/routing/router.dart
new file mode 100644
index 0000000..a2a269d
--- /dev/null
+++ b/lib/routing/router.dart
@@ -0,0 +1,30 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_lio_integration/features/products/model/product.dart';
+import 'package:flutter_lio_integration/routing/routes.dart';
+import 'package:go_router/go_router.dart';
+import 'package:flutter_lio_integration/features/payment_checkout/payment_checkout_screen.dart';
+import 'package:flutter_lio_integration/features/products/product_list.dart';
+
+final GoRouter router = GoRouter(
+ initialLocation: Routes.home,
+ routes: [
+ GoRoute(
+ path: Routes.home,
+ builder: (context, state) => ProductList(),
+ ),
+ GoRoute(
+ path: Routes.checkout,
+ builder: (context, state) {
+ final product = state.extra as Product;
+ return PaymentCheckoutScreen(product: product);
+ },
+ ),
+ ],
+ errorPageBuilder: (context, state) => MaterialPage(
+ child: Scaffold(
+ body: Center(
+ child: Text('Sem nenhum ${state.path} por aqui!'),
+ ),
+ ),
+ ),
+);
diff --git a/lib/routing/routes.dart b/lib/routing/routes.dart
new file mode 100644
index 0000000..7ada521
--- /dev/null
+++ b/lib/routing/routes.dart
@@ -0,0 +1,4 @@
+abstract final class Routes {
+ static const home = '/';
+ static const checkout = '/checkout';
+}
\ No newline at end of file
diff --git a/pubspec.yaml b/pubspec.yaml
index ac80264..2fb666b 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -14,7 +14,7 @@ description: Exemplo de integração Flutter com Lio - Cielo
version: 1.0.0+1
environment:
- sdk: ">=2.1.0 <3.0.0"
+ sdk: ">=3.0.0 < 4.0.0"
dependencies:
flutter:
@@ -22,9 +22,11 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^0.1.2
- url_launcher: ^5.2.7
- uni_links: ^0.2.0
+ cupertino_icons: ^1.0.8
+ url_launcher: ^6.3.1
+ app_links: ^6.4.0
+ go_router: ^14.8.1
+
dev_dependencies:
flutter_test:
From 57cb00b7349b3e89d1898257c6fc56f2004765e2 Mon Sep 17 00:00:00 2001
From: sousa-p
Date: Wed, 12 Mar 2025 11:55:43 -0300
Subject: [PATCH 2/4] :rocket: feat: melhorando cores e layout
---
.../model/payment_response_success.dart | 28 +++++-----
.../payment_checkout_screen.dart | 51 ++++++++++--------
lib/features/products/model/product.dart | 53 +++++++++++++------
lib/features/products/product_list.dart | 16 ++++--
lib/main.dart | 4 +-
lib/routing/routes.dart | 2 +-
6 files changed, 93 insertions(+), 61 deletions(-)
diff --git a/lib/features/payment_checkout/model/payment_response_success.dart b/lib/features/payment_checkout/model/payment_response_success.dart
index 62e9981..5e23b5a 100644
--- a/lib/features/payment_checkout/model/payment_response_success.dart
+++ b/lib/features/payment_checkout/model/payment_response_success.dart
@@ -1,7 +1,6 @@
import 'dart:convert';
import 'package:flutter_lio_integration/features/payment_checkout/model/payment.dart';
-
class PaymentCheckoutResponseSuccess {
String? createdAt;
String? id;
@@ -52,8 +51,7 @@ class PaymentCheckoutResponseSuccess {
? null
: List.from(
json["payments"].map((x) => Payment.fromMap(x))),
- pendingAmount:
- json["pendingAmount"],
+ pendingAmount: json["pendingAmount"],
price: json["price"],
reference: json["reference"],
status: json["status"],
@@ -81,16 +79,17 @@ class PaymentCheckoutResponseSuccess {
"updatedAt": updatedAt == null ? null : updatedAt,
};
}
+
class Item {
- String ?description;
- String ?details;
- String ?id;
- String ?name;
- int ?quantity;
- String ?reference;
- String ?sku;
- String ?unitOfMeasure;
- int ?unitPrice;
+ String? description;
+ String? details;
+ String? id;
+ String? name;
+ int? quantity;
+ String? reference;
+ String? sku;
+ String? unitOfMeasure;
+ int? unitPrice;
Item({
this.description,
@@ -116,8 +115,7 @@ class Item {
quantity: json["quantity"],
reference: json["reference"],
sku: json["sku"],
- unitOfMeasure:
- json["unitOfMeasure"],
+ unitOfMeasure: json["unitOfMeasure"],
unitPrice: json["unitPrice"],
);
@@ -132,4 +130,4 @@ class Item {
"unitOfMeasure": unitOfMeasure,
"unitPrice": unitPrice,
};
-}
\ No newline at end of file
+}
diff --git a/lib/features/payment_checkout/payment_checkout_screen.dart b/lib/features/payment_checkout/payment_checkout_screen.dart
index 47ded93..8ee5a6b 100644
--- a/lib/features/payment_checkout/payment_checkout_screen.dart
+++ b/lib/features/payment_checkout/payment_checkout_screen.dart
@@ -29,7 +29,17 @@ class _PaymentCheckoutScreenState extends State
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
- title: Text("Checkout de Venda"),
+ title: Text(
+ "Checkout de Venda",
+ style: TextStyle(
+ color: Colors.white,
+ ),
+ ),
+ iconTheme: IconThemeData(
+ color: Colors.white,
+ ),
+ backgroundColor: Theme.of(context).colorScheme.primary,
+ elevation: 16,
),
body: Container(
alignment: Alignment.center,
@@ -55,16 +65,12 @@ class _PaymentCheckoutScreenState extends State
),
Padding(
padding: const EdgeInsets.all(8.0),
- child: ButtonTheme(
- height: 50.0,
- minWidth: MediaQuery.of(context).size.width,
+ child: SizedBox(
+ width: MediaQuery.of(context).size.width,
+ height: 58,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
- backgroundColor: Theme.of(context).colorScheme.tertiary,
- elevation: 4.0,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(50.0),
- ),
+ backgroundColor: Theme.of(context).colorScheme.primary,
),
child: Text(
"Crédito Avista",
@@ -72,23 +78,21 @@ class _PaymentCheckoutScreenState extends State
),
onPressed: () {
presenter.checkout(
- PaymentType.creditoAVista, widget.product);
+ PaymentType.creditoAVista,
+ widget.product,
+ );
},
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
- child: ButtonTheme(
- height: 50.0,
- minWidth: MediaQuery.of(context).size.width,
+ child: SizedBox(
+ width: MediaQuery.of(context).size.width,
+ height: 58,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
- backgroundColor: Theme.of(context).colorScheme.tertiary,
- elevation: 4.0,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(50.0),
- ),
+ backgroundColor: Theme.of(context).colorScheme.primary,
),
child: Text(
"Débito Avista",
@@ -109,11 +113,12 @@ class _PaymentCheckoutScreenState extends State
Expanded(
flex: 1,
child: SingleChildScrollView(
- child: Text(
- message,
- style: TextStyle(fontSize: 16.0),
- textAlign: TextAlign.center,
- )),
+ child: Text(
+ message,
+ style: TextStyle(fontSize: 16.0),
+ textAlign: TextAlign.center,
+ ),
+ ),
),
],
),
diff --git a/lib/features/products/model/product.dart b/lib/features/products/model/product.dart
index 83e2210..0c8419d 100644
--- a/lib/features/products/model/product.dart
+++ b/lib/features/products/model/product.dart
@@ -13,26 +13,49 @@ class Product {
this.unitPrice,
});
+ factory Product.fromJson(Map json) {
+ return Product(
+ name: json['name'] as String?,
+ quantity: json['quantity'] as int?,
+ sku: json['sku'] as String?,
+ unitOfMeasure: json['unitOfMeasure'] as String?,
+ unitPrice: json['unitPrice'] as int?,
+ );
+ }
+
+ Map toJson() {
+ return {
+ 'name': name,
+ 'quantity': quantity,
+ 'sku': sku,
+ 'unitOfMeasure': unitOfMeasure,
+ 'unitPrice': unitPrice,
+ };
+ }
+
static List list() {
return [
Product(
- name: "COCA-COLA LATA",
- quantity: 1,
- sku: "1111",
- unitOfMeasure: "unidade",
- unitPrice: 1),
+ name: "COCA-COLA LATA",
+ quantity: 1,
+ sku: "1111",
+ unitOfMeasure: "unidade",
+ unitPrice: 1,
+ ),
Product(
- name: "X-BURGUER",
- quantity: 2,
- sku: "2222",
- unitOfMeasure: "unidade",
- unitPrice: 2),
+ name: "X-BURGUER",
+ quantity: 2,
+ sku: "2222",
+ unitOfMeasure: "unidade",
+ unitPrice: 2,
+ ),
Product(
- name: "FANTA LATA",
- quantity: 2,
- sku: "3333",
- unitOfMeasure: "unidade",
- unitPrice: 3),
+ name: "FANTA LATA",
+ quantity: 2,
+ sku: "3333",
+ unitOfMeasure: "unidade",
+ unitPrice: 3,
+ ),
];
}
}
diff --git a/lib/features/products/product_list.dart b/lib/features/products/product_list.dart
index f10b43c..e84b56b 100644
--- a/lib/features/products/product_list.dart
+++ b/lib/features/products/product_list.dart
@@ -15,7 +15,12 @@ class _ProductListState extends State {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
- title: Text("Escolha um produto"),
+ title: Text(
+ "Escolha um produto",
+ style: TextStyle(color: Colors.white),
+ ),
+ backgroundColor: Theme.of(context).colorScheme.primary,
+ elevation: 16,
),
body: ListView.separated(
itemCount: items.length,
@@ -24,12 +29,13 @@ class _ProductListState extends State {
title: Text(
items[index].name ?? '',
style: TextStyle(
- color: Colors.blue,
- fontSize: 20.0,
- fontWeight: FontWeight.bold),
+ color: Theme.of(context).colorScheme.secondary,
+ fontSize: 20.0,
+ fontWeight: FontWeight.bold,
+ ),
),
onTap: () {
- context.go(Routes.checkout, extra: items[index]);
+ context.push(Routes.checkout, extra: items[index]);
},
);
}),
diff --git a/lib/main.dart b/lib/main.dart
index d6dc152..f438b1c 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -10,8 +10,8 @@ class MyApp extends StatelessWidget {
title: 'SDK Integration',
routerConfig: router,
debugShowCheckedModeBanner: false,
- theme: ThemeData(
- primarySwatch: Colors.blue,
+ theme: ThemeData(
+ colorSchemeSeed: Colors.blue,
),
);
}
diff --git a/lib/routing/routes.dart b/lib/routing/routes.dart
index 7ada521..2c4acdf 100644
--- a/lib/routing/routes.dart
+++ b/lib/routing/routes.dart
@@ -1,4 +1,4 @@
abstract final class Routes {
- static const home = '/';
+ static const home ='/';
static const checkout = '/checkout';
}
\ No newline at end of file
From 92e912f5c9838ccc1d03f634737cfdabde320855 Mon Sep 17 00:00:00 2001
From: sousa-p
Date: Thu, 13 Mar 2025 07:37:07 -0300
Subject: [PATCH 3/4] :memo: update: README.md
---
README.md | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index f050e91..eb9a091 100644
--- a/README.md
+++ b/README.md
@@ -45,6 +45,8 @@ Seu valor pode ser visualizado na coluna Client ID, dentro do menu
## Libs Auxiliares
Foi necessário o uso das bibliotecas auxiliares:
-Url_Launcher - [url_launcher](https://pub.dev/packages/url_launcher#-readme-tab-)
+App_Links - [api_links](https://pub.dev/packages/uni_links)
-Uni_Links - [uni_links](https://pub.dev/packages/uni_links)
+Url_Launcher - [url_launcher](https://pub.dev/packages/url_launcher)
+
+Go_Router - [go_router](https://pub.dev/packages/go_router)
From 76b086e8a722e2246651aaf67e553757c48a8e98 Mon Sep 17 00:00:00 2001
From: sousa-p
Date: Thu, 13 Mar 2025 08:10:45 -0300
Subject: [PATCH 4/4] :rocket: feat: adicionando reatividade via valueNotifier
---
.../payment_checkout_presenter.dart | 13 +-
.../payment_checkout_screen.dart | 155 +++++++++---------
.../payment_checkout_view.dart | 3 -
3 files changed, 81 insertions(+), 90 deletions(-)
delete mode 100644 lib/features/payment_checkout/payment_checkout_view.dart
diff --git a/lib/features/payment_checkout/payment_checkout_presenter.dart b/lib/features/payment_checkout/payment_checkout_presenter.dart
index 3fd9cdc..1caa77a 100644
--- a/lib/features/payment_checkout/payment_checkout_presenter.dart
+++ b/lib/features/payment_checkout/payment_checkout_presenter.dart
@@ -1,18 +1,18 @@
import 'dart:convert';
import 'package:app_links/app_links.dart';
+import 'package:flutter/material.dart';
import 'package:flutter_lio_integration/features/payment_checkout/model/Payment_request.dart';
import 'package:flutter_lio_integration/features/payment_checkout/model/payment_type.dart';
-import 'package:flutter_lio_integration/features/payment_checkout/payment_checkout_view.dart';
import 'package:flutter_lio_integration/features/products/model/product.dart';
import 'package:url_launcher/url_launcher.dart';
import 'model/payment_response.dart';
import 'model/payment_response_success.dart';
class PaymentCheckoutPresenter {
- PaymentCheckoutView view;
final Product product;
+ final message = ValueNotifier('');
- PaymentCheckoutPresenter(this.product) : view = PaymentCheckoutView();
+ PaymentCheckoutPresenter(this.product);
Future checkout(PaymentType paymentType, Product product) async {
final payment = PaymentRequest.makeOrder(paymentType, product);
@@ -25,15 +25,16 @@ class PaymentCheckoutPresenter {
await launchUrl(uri);
return;
}
- view.showMessage('Erro: App URI não instalado.');
+
+ message.value = "Erro: App URI não instalado.";
}
void onFailure(PaymentCheckoutResponse response) {
- view.showMessage(response.toJson());
+ message.value = response.toJson();
}
void onSuccess(PaymentCheckoutResponseSuccess response) {
- view.showMessage(response.toJson());
+ message.value = response.toJson();
}
final AppLinks _appLinks = AppLinks();
diff --git a/lib/features/payment_checkout/payment_checkout_screen.dart b/lib/features/payment_checkout/payment_checkout_screen.dart
index 8ee5a6b..ad1440a 100644
--- a/lib/features/payment_checkout/payment_checkout_screen.dart
+++ b/lib/features/payment_checkout/payment_checkout_screen.dart
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_lio_integration/features/payment_checkout/model/payment_type.dart';
import 'package:flutter_lio_integration/features/payment_checkout/payment_checkout_presenter.dart';
-import 'package:flutter_lio_integration/features/payment_checkout/payment_checkout_view.dart';
import 'package:flutter_lio_integration/features/products/model/product.dart';
class PaymentCheckoutScreen extends StatefulWidget {
@@ -13,10 +12,8 @@ class PaymentCheckoutScreen extends StatefulWidget {
State createState() => _PaymentCheckoutScreenState();
}
-class _PaymentCheckoutScreenState extends State
- implements PaymentCheckoutView {
+class _PaymentCheckoutScreenState extends State {
late PaymentCheckoutPresenter presenter;
- String message = "";
@override
void initState() {
@@ -43,92 +40,88 @@ class _PaymentCheckoutScreenState extends State
),
body: Container(
alignment: Alignment.center,
- child: Column(
- children: [
- SizedBox(
- height: 20,
- ),
- Text(
- widget.product.name ?? '',
- style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
- ),
- SizedBox(
- height: 10,
- ),
- Text("Quantidade: ${widget.product.quantity}"),
- SizedBox(
- height: 10,
- ),
- Text("Preço: R\$ ${widget.product.unitPrice?.roundToDouble()}"),
- SizedBox(
- height: 10,
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: SizedBox(
- width: MediaQuery.of(context).size.width,
- height: 58,
- child: ElevatedButton(
- style: ElevatedButton.styleFrom(
- backgroundColor: Theme.of(context).colorScheme.primary,
- ),
- child: Text(
- "Crédito Avista",
- style: TextStyle(color: Colors.white, fontSize: 18),
+ child: SingleChildScrollView(
+ child: Column(
+ children: [
+ SizedBox(
+ height: 20,
+ ),
+ Text(
+ widget.product.name ?? "",
+ style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
+ ),
+ SizedBox(
+ height: 10,
+ ),
+ Text("Quantidade: ${widget.product.quantity}"),
+ SizedBox(
+ height: 10,
+ ),
+ Text("Preço: R\$ ${widget.product.unitPrice?.roundToDouble()}"),
+ SizedBox(
+ height: 10,
+ ),
+ Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: SizedBox(
+ width: MediaQuery.of(context).size.width,
+ height: 58,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Theme.of(context).colorScheme.primary,
+ ),
+ child: Text(
+ "Crédito Avista",
+ style: TextStyle(color: Colors.white, fontSize: 18),
+ ),
+ onPressed: () {
+ presenter.checkout(
+ PaymentType.creditoAVista,
+ widget.product,
+ );
+ },
),
- onPressed: () {
- presenter.checkout(
- PaymentType.creditoAVista,
- widget.product,
- );
- },
),
),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: SizedBox(
- width: MediaQuery.of(context).size.width,
- height: 58,
- child: ElevatedButton(
- style: ElevatedButton.styleFrom(
- backgroundColor: Theme.of(context).colorScheme.primary,
- ),
- child: Text(
- "Débito Avista",
- style: TextStyle(color: Colors.white, fontSize: 18),
+ Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: SizedBox(
+ width: MediaQuery.of(context).size.width,
+ height: 58,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Theme.of(context).colorScheme.primary,
+ ),
+ child: Text(
+ "Débito Avista",
+ style: TextStyle(color: Colors.white, fontSize: 18),
+ ),
+ onPressed: () {
+ presenter.checkout(
+ PaymentType.debitoAVista,
+ widget.product,
+ );
+ },
),
- onPressed: () {
- presenter.checkout(
- PaymentType.debitoAVista,
- widget.product,
- );
- },
),
),
- ),
- SizedBox(
- height: 30,
- ),
- Expanded(
- flex: 1,
- child: SingleChildScrollView(
- child: Text(
- message,
- style: TextStyle(fontSize: 16.0),
- textAlign: TextAlign.center,
- ),
+ SizedBox(
+ height: 30,
+ ),
+ ValueListenableBuilder(
+ valueListenable: presenter.message,
+ builder: (context, message, _) {
+ return Text(
+ message,
+ style: TextStyle(fontSize: 16.0),
+ textAlign: TextAlign.center,
+ );
+ },
),
- ),
- ],
+ ],
+ ),
),
),
);
}
-
- @override
- void showMessage(String message) {
- this.message = message;
- setState(() {});
- }
}
diff --git a/lib/features/payment_checkout/payment_checkout_view.dart b/lib/features/payment_checkout/payment_checkout_view.dart
deleted file mode 100644
index dc81223..0000000
--- a/lib/features/payment_checkout/payment_checkout_view.dart
+++ /dev/null
@@ -1,3 +0,0 @@
-class PaymentCheckoutView {
- void showMessage(String message) {}
-}