Commit 58351685 authored by MDDmac's avatar MDDmac

update simulator prepaid_lib_flutter

parent b622eaab
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig" #include "Generated.xcconfig"
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig" #include "Generated.xcconfig"
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
import 'package:shared_preferences/shared_preferences.dart';
class PreferencesHelper {
static Future<SharedPreferences> get _instance async => _prefsInstance ??= await SharedPreferences.getInstance();
static SharedPreferences _prefsInstance;
static void init() async {
_prefsInstance = await _instance;
}
static String getString(String key, [String defValue]) {
return _prefsInstance.getString(key) ?? defValue ?? "0";
}
static void setString(String key, String value) async {
_prefsInstance.setString(key, value);
}
static int getInt(String key, [String defValue]) {
return _prefsInstance.getInt(key) ?? defValue ?? 0;
}
static void setInt(String key, int value) async {
_prefsInstance.setInt(key, value);
}
static bool getBool(String key, [var defValue]) {
return _prefsInstance.getBool(key) ?? defValue ?? false;
}
static void setBool(String key, var value) async {
_prefsInstance.setBool(key, value);
}
}
\ No newline at end of file
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_mdd_simulator/screen/TapCard.dart'; import 'package:flutter_mdd_simulator/screen/TapCard.dart';
import 'package:intl/intl.dart';
import 'package:prepaid_lib_flutter/unik_lib_flutter.dart'; import 'package:prepaid_lib_flutter/unik_lib_flutter.dart';
import 'package:intl/intl.dart';
import 'PreferencesHelper.dart';
void main() { void main() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
PreferencesHelper.init();
runApp(MyApp()); runApp(MyApp());
} }
...@@ -36,47 +34,72 @@ class _MyAppState extends State<NfcScan> { ...@@ -36,47 +34,72 @@ class _MyAppState extends State<NfcScan> {
String paidAmount; String paidAmount;
String _identifier = 'Unknown'; String _identifier = 'Unknown';
String _bankName; String _bankName;
bool isSuccessInit;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
String mid = "1234567abc"; initLibrary();
int env = 0; // 0 = dev, 1 = prod }
UnikLibFlutter.initUnikLib(mid, env); //initial library
void initLibrary() async {
isSuccessInit = await UnikLibFlutter.initUnikLib(
"49df5f81d59fae23ec6f542372fc9497" /*"1234567abc"*/, 1);
print("isSuccessInit $isSuccessInit");
} }
//function to get card info
void getCardInfo() async { void getCardInfo() async {
/// optional you can use List<String> varName = List<String>.filled(1, "");
List<String> cardUid = List(1); List<String> cardUid = List(1);
List<String> cardNumber = List(1); List<String> cardNumber = List(1);
List<String> balance = List(1); List<String> balance = List(1);
List<String> bankName = List(1); List<String> bankName = List(1);
List<String> cardAttr = List(1);
List<String> cardInfo = List(1);
bool isSuccess = await UnikLibFlutter.getCardInfo( bool isSuccess = await UnikLibFlutter.getCardInfo(
cardUid, cardNumber, balance, bankName, cardAttr, cardInfo); cardUid, cardNumber, balance, bankName,
startPooling: true,
callbackTimeout: (bool isTimeout) => print("timeout $isTimeout"),
errorNfc: (bool nfcIsNotDetected) =>
print("--> errorNfc $nfcIsNotDetected"));
print(
"isSuccess $isSuccess, cardNumber ${cardNumber[0]}, balance ${balance[0]}, bankName ${bankName[0]}");
_setStateCard(isSuccess, cardNumber[0], balance[0], bankName[0]); _setStateCard(isSuccess, cardNumber[0], balance[0], bankName[0]);
} }
//function to update balance
void updateBalance() async { void updateBalance() async {
List<String> status = List(1); List<String> status = [null];
List<String> cardNumber = List(1); List<String> cardNumber = [null];
List<String> balance = List(1); List<String> balance = [null];
List<String> bankName = List(1); List<String> bankName = [null];
bool isSuccess = await UnikLibFlutter.updateBalance( List<String> beforeBalance = [null];
status, cardNumber, balance, bankName); if (isSuccessInit) {
print("status update ${status[0]}"); bool isSuccess = await UnikLibFlutter.updateBalance(
this.setState(() { status,
_status = status[0]; cardNumber,
}); balance,
_setStateCard(isSuccess, cardNumber[0], balance[0], bankName[0]); bankName,
beforeBalance,
"085735442829",
"developer@mdd.co.id",
callbackState: (String stateOperation) =>
(stateOperation == UnikLibFlutter.WAITING_STATUS)
? print("state operation WAITING")
: print("state operation DONE"),
callbackTimeout: (bool isTimeout) => print("timeout $isTimeout"),
errorNfc: (bool value) => print("error nfc $value"));
print("isSuccess $isSuccess");
print("status update ${status[0]}");
this.setState(() {
_status = status[0];
});
_setStateCard(isSuccess, cardNumber[0], balance[0], bankName[0]);
}
} }
//function to change UI card and balance information void _setStateCard(
void _setStateCard(bool isSuccess, String cardNumber, String balance, bool isSuccess, String cardNumber, String balance, String bankName) {
String bankName) {
if (isSuccess) { if (isSuccess) {
this.setState(() { this.setState(() {
_cardNumber = cardNumber ?? "0000000000000000"; _cardNumber = cardNumber ?? "0000000000000000";
...@@ -110,10 +133,7 @@ class _MyAppState extends State<NfcScan> { ...@@ -110,10 +133,7 @@ class _MyAppState extends State<NfcScan> {
context: context, context: context,
builder: (builder) { builder: (builder) {
return new Container( return new Container(
height: MediaQuery height: MediaQuery.of(context).size.height * height,
.of(context)
.size
.height * height,
color: Colors.transparent, color: Colors.transparent,
//could change this to Color(0xFF737373), //could change this to Color(0xFF737373),
//so you don't have to change MaterialApp canvasColor //so you don't have to change MaterialApp canvasColor
...@@ -127,23 +147,14 @@ class _MyAppState extends State<NfcScan> { ...@@ -127,23 +147,14 @@ class _MyAppState extends State<NfcScan> {
return Scaffold( return Scaffold(
body: Container( body: Container(
height: MediaQuery height: MediaQuery.of(context).size.height,
.of(context) width: MediaQuery.of(context).size.width,
.size
.height,
width: MediaQuery
.of(context)
.size
.width,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container( Container(
width: MediaQuery width: MediaQuery.of(context).size.width,
.of(context)
.size
.width,
height: 200, height: 200,
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
...@@ -186,10 +197,11 @@ class _MyAppState extends State<NfcScan> { ...@@ -186,10 +197,11 @@ class _MyAppState extends State<NfcScan> {
Text( Text(
_cardNumber.replaceAllMapped( _cardNumber.replaceAllMapped(
RegExp(r".{4}"), RegExp(r".{4}"),
(match) => "${match.group( (match) => "${match.group(0)} "),
0)} "),
style: TextStyle( style: TextStyle(
color: Colors.white, fontSize: 18)), color: Colors.white,
fontSize: 18) ??
"0000000000000000"),
SizedBox( SizedBox(
height: 17, height: 17,
), ),
...@@ -203,7 +215,7 @@ class _MyAppState extends State<NfcScan> { ...@@ -203,7 +215,7 @@ class _MyAppState extends State<NfcScan> {
Text( Text(
NumberFormat.simpleCurrency( NumberFormat.simpleCurrency(
locale: 'id_ID') locale: 'id_ID')
.format(int.parse(_balance)), .format(int.parse(_balance) ?? "0"),
style: TextStyle(color: Colors.white)), style: TextStyle(color: Colors.white)),
], ],
)) ))
...@@ -229,16 +241,21 @@ class _MyAppState extends State<NfcScan> { ...@@ -229,16 +241,21 @@ class _MyAppState extends State<NfcScan> {
), ),
Align( Align(
alignment: Alignment.center, alignment: Alignment.center,
child: child: _isLoading
_isLoading ? CircularProgressIndicator() : Text(_status), ? CircularProgressIndicator()
: Text(_status ?? "Unknown"),
) )
], ],
), ),
)), )),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: () { onPressed: () {
getCardInfo(); if (isSuccessInit) {
_showBottomSheet(TapCard(), 0.50); getCardInfo();
_showBottomSheet(TapCard(), 0.50);
} else {
print("Init Failed");
}
}, },
child: const Icon(Icons.cached), child: const Icon(Icons.cached),
backgroundColor: Colors.blue, backgroundColor: Colors.blue,
...@@ -246,20 +263,4 @@ class _MyAppState extends State<NfcScan> { ...@@ -246,20 +263,4 @@ class _MyAppState extends State<NfcScan> {
); );
} }
Future<void> initPlatformState() async {
// String identifier;
// try {
// identifier = await UniqueIdentifier.serial;
// } on PlatformException {
// identifier = 'Failed to get Unique Identifier';
// }
//
// if (!mounted) return;
//
// setState(() {
// _identifier = identifier;
// });
//
// print("Unique $_identifier");
}
} }
...@@ -7,7 +7,7 @@ packages: ...@@ -7,7 +7,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.5.0" version: "2.8.1"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
...@@ -28,7 +28,7 @@ packages: ...@@ -28,7 +28,7 @@ packages:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
...@@ -64,20 +64,6 @@ packages: ...@@ -64,20 +64,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.1"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
...@@ -102,25 +88,6 @@ packages: ...@@ -102,25 +88,6 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.3"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -128,13 +95,6 @@ packages: ...@@ -128,13 +95,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.16.1" version: "0.16.1"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
json_annotation: json_annotation:
dependency: transitive dependency: transitive
description: description:
...@@ -155,7 +115,7 @@ packages: ...@@ -155,7 +115,7 @@ packages:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.7.0"
ndef: ndef:
dependency: transitive dependency: transitive
description: description:
...@@ -170,104 +130,13 @@ packages: ...@@ -170,104 +130,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+2"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.5"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
prepaid_lib_flutter: prepaid_lib_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
name: prepaid_lib_flutter name: prepaid_lib_flutter
url: "https://pub.dartlang.org" url: "http://202.158.132.228:4000"
source: hosted
version: "0.0.7"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.12+4"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.2+4"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+11"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2+7"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.0.2+3" version: "0.0.6"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
...@@ -279,7 +148,7 @@ packages: ...@@ -279,7 +148,7 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.1"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
...@@ -314,7 +183,7 @@ packages: ...@@ -314,7 +183,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.19" version: "0.4.2"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
...@@ -336,20 +205,6 @@ packages: ...@@ -336,20 +205,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
sdks: sdks:
dart: ">=2.12.0 <3.0.0" dart: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0" flutter: ">=1.20.0"
...@@ -28,11 +28,14 @@ dependencies: ...@@ -28,11 +28,14 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
shared_preferences: ^0.5.12+4
flutter_nfc_kit: ^2.2.1 flutter_nfc_kit: ^2.2.1
flutter_gifimage: ^1.0.1 flutter_gifimage: ^1.0.1
intl: ^0.16.1 intl: ^0.16.1
prepaid_lib_flutter: ^0.0.7 prepaid_lib_flutter:
hosted:
name: prepaid_lib_flutter
url: http://202.158.132.228:4000
version: 0.0.6
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment