master
suvaysov 2023-01-27 11:00:21 +06:00
parent 8e654c5ab1
commit e224df165a
11 changed files with 255 additions and 7 deletions

View File

@ -0,0 +1,39 @@
{
"project_info": {
"project_number": "1086013480150",
"project_id": "aman-f670e",
"storage_bucket": "aman-f670e.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1086013480150:android:d00d738289818373f17d77",
"android_client_info": {
"package_name": "kz.com.aman.kassa"
}
},
"oauth_client": [
{
"client_id": "1086013480150-tbavt0qel11hs9eqsfni0j8hhr1nbis1.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAlAhTjrXj0s1Qep2_mP_u4QtMnltMi4RA"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1086013480150-tbavt0qel11hs9eqsfni0j8hhr1nbis1.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

View File

@ -44,12 +44,14 @@
android:resource="@drawable/splash" android:resource="@drawable/splash"
/> />
--> -->
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<!-- <!--
Don't delete the meta-data below. Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java This is used by the Flutter tool to generate GeneratedPluginRegistrant.java

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>1086013480150-93mcqf1l60dvmd2k1lkg2ikmvm3u29ca.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.1086013480150-93mcqf1l60dvmd2k1lkg2ikmvm3u29ca</string>
<key>API_KEY</key>
<string>AIzaSyApELiWrEflqtXPo8cndFnPW0sRVVHmkYQ</string>
<key>GCM_SENDER_ID</key>
<string>1086013480150</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.kz.amankassaflutter</string>
<key>PROJECT_ID</key>
<string>aman-f670e</string>
<key>STORAGE_BUCKET</key>
<string>aman-f670e.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:1086013480150:ios:958c91234e46010cf17d77</string>
</dict>
</plist>

View File

@ -0,0 +1,7 @@
{
"file_generated_by": "FlutterFire CLI",
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
"GOOGLE_APP_ID": "1:1086013480150:ios:958c91234e46010cf17d77",
"FIREBASE_PROJECT_ID": "aman-f670e",
"GCM_SENDER_ID": "1086013480150"
}

View File

@ -4,15 +4,17 @@ import 'package:aman_kassa_flutter/core/models/check_item.dart';
class CheckData { class CheckData {
final String? type; final String? type;
num? card; num? card;
num? mobile;
String? contragent; String? contragent;
final List<CheckItem>? items; final List<CheckItem>? items;
CardData? cardData; CardData? cardData;
CheckData({this.type, this.card, this.items, this.cardData, this.contragent}); CheckData({this.type, this.card, this.mobile, this.items, this.cardData, this.contragent});
static CheckData fromJson(Map<String, dynamic> json) { static CheckData fromJson(Map<String, dynamic> json) {
return CheckData( return CheckData(
type: json['type'] as String?, type: json['type'] as String?,
card: json['card'] as num?, card: json['card'] as num?,
mobile: json['mobile'] as num?,
items: (json['items'] as List).map((e) => CheckItem.fromJson(e)).toList(), items: (json['items'] as List).map((e) => CheckItem.fromJson(e)).toList(),
cardData: CardData.fromJson(json['cardData']), cardData: CardData.fromJson(json['cardData']),
contragent: json['type'] as String?, contragent: json['type'] as String?,
@ -22,6 +24,7 @@ class CheckData {
{ {
'type': type, 'type': type,
'card': card, 'card': card,
'mobile': mobile,
'items': items?.map((e) => e.toJson()).toList(), 'items': items?.map((e) => e.toJson()).toList(),
'cardData': cardData?.toJson(), 'cardData': cardData?.toJson(),
'contragent': contragent, 'contragent': contragent,

View File

@ -178,14 +178,14 @@ class ApiService extends BaseService {
String body; String body;
if(bodyEntry) { // log.i(uri);
// log.i(jsonEncode(headers));
// log.i(jsonEncode(requestBody));
if(bodyEntry) {
http.Response res = await http.post(uri, body: jsonEncode(requestBody), headers: headers ); http.Response res = await http.post(uri, body: jsonEncode(requestBody), headers: headers );
body = res.body; body = res.body;
} else { } else {
// log.i(uri);
// log.i(jsonEncode(headers));
// log.i(requestBody);
var request = http.MultipartRequest('POST', uri) var request = http.MultipartRequest('POST', uri)
..headers.addAll(headers) ..headers.addAll(headers)
..fields.addAll(requestBody); ..fields.addAll(requestBody);

View File

@ -78,6 +78,8 @@ class DataService extends BaseService {
CheckData checkData = CheckData(type: tradeType, items: itemsList); CheckData checkData = CheckData(type: tradeType, items: itemsList);
if ((paymentType ?? 'cash') == 'card') { if ((paymentType ?? 'cash') == 'card') {
checkData.card = summ; checkData.card = summ;
} else if ((paymentType ?? 'cash') == 'mobile') {
checkData.mobile = summ;
} }
return checkData; return checkData;
} }
@ -104,6 +106,8 @@ class DataService extends BaseService {
CheckData checkData = CheckData(type: tradeType, items: itemsList); CheckData checkData = CheckData(type: tradeType, items: itemsList);
if ((paymentType ?? 'cash') == 'card') { if ((paymentType ?? 'cash') == 'card') {
checkData.card = summ; checkData.card = summ;
} else if ((paymentType ?? 'cash') == 'mobile') {
checkData.mobile = summ;
} }
return checkData; return checkData;
} }

69
lib/firebase_options.dart Normal file
View File

@ -0,0 +1,69 @@
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for web - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for macos - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}
static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyAlAhTjrXj0s1Qep2_mP_u4QtMnltMi4RA',
appId: '1:1086013480150:android:d00d738289818373f17d77',
messagingSenderId: '1086013480150',
projectId: 'aman-f670e',
storageBucket: 'aman-f670e.appspot.com',
);
static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyApELiWrEflqtXPo8cndFnPW0sRVVHmkYQ',
appId: '1:1086013480150:ios:958c91234e46010cf17d77',
messagingSenderId: '1086013480150',
projectId: 'aman-f670e',
storageBucket: 'aman-f670e.appspot.com',
iosClientId: '1086013480150-93mcqf1l60dvmd2k1lkg2ikmvm3u29ca.apps.googleusercontent.com',
iosBundleId: 'com.kz.amankassaflutter',
);
}

View File

@ -1,13 +1,15 @@
//general //general
import 'dart:io'; import 'dart:io';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_redux/flutter_redux.dart'; import 'package:flutter_redux/flutter_redux.dart';
import 'package:aman_kassa_flutter/shared/app_colors.dart'; import 'package:aman_kassa_flutter/shared/app_colors.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
//service & tools //service & tools
import 'package:aman_kassa_flutter/redux/store.dart'; import 'package:aman_kassa_flutter/redux/store.dart';
@ -22,7 +24,10 @@ import 'views/start_up/start_up_view.dart';
//main start //main start
void main() async { void main() async {
HttpOverrides.global = MyHttpOverrides(); // HttpOverrides.global = MyHttpOverrides();
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
HttpOverrides.global = MyHttpOverrides(); HttpOverrides.global = MyHttpOverrides();
@ -34,10 +39,51 @@ void main() async {
yield LicenseEntryWithLineBreaks(['google_fonts'], license); yield LicenseEntryWithLineBreaks(['google_fonts'], license);
}); });
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
FirebaseMessaging messaging = FirebaseMessaging.instance;
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
print('User granted permission: ${settings.authorizationStatus}');
await FirebaseMessaging.instance.subscribeToTopic('all');
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
if (message.notification != null) {
locator<DialogService>().showDialog(description: message.notification?.body ?? '');
}
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async {
if (message.notification != null) {
locator<DialogService>().showDialog(description: message.notification?.body ?? '');
}
});
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
await Redux.init(); await Redux.init();
runApp(MainApplication()); runApp(MainApplication());
} }
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
// If you're going to use other Firebase services in the background, such as Firestore,
// make sure you call `initializeApp` before using other Firebase services.
await Firebase.initializeApp();
}
class MyHttpOverrides extends HttpOverrides { class MyHttpOverrides extends HttpOverrides {
@override @override
HttpClient createHttpClient(SecurityContext? context) { HttpClient createHttpClient(SecurityContext? context) {

View File

@ -155,6 +155,48 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.1.2" version: "6.1.2"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "1.20.1"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.5.0"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.1"
firebase_messaging:
dependency: "direct main"
description:
name: firebase_messaging
url: "https://pub.dartlang.org"
source: hosted
version: "12.0.2"
firebase_messaging_platform_interface:
dependency: transitive
description:
name: firebase_messaging_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.1"
firebase_messaging_web:
dependency: transitive
description:
name: firebase_messaging_web
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.1"
fixnum: fixnum:
dependency: transitive dependency: transitive
description: description:

View File

@ -41,6 +41,8 @@ dependencies:
bluetooth_print: bluetooth_print:
path: ../bluetooth_print path: ../bluetooth_print
flutter_blue: ^0.8.0 flutter_blue: ^0.8.0
firebase_messaging: ^12.0.2
firebase_core: ^1.20.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter