43 lines
1.1 KiB
Dart
43 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:praresi/presentation/controllers/resi_controller.dart';
|
|
import 'package:firebase_auth/firebase_auth.dart';
|
|
|
|
class ResiInputHandler {
|
|
static final ResiController _controller = Get.find<ResiController>();
|
|
static final FirebaseAuth _auth = FirebaseAuth.instance;
|
|
|
|
/// Fungsi untuk menerima input dari bubble
|
|
static Future<void> saveResiFromBubble(String inputText) async {
|
|
final user = _auth.currentUser;
|
|
if (user == null) {
|
|
Get.snackbar(
|
|
'Gagal',
|
|
'User belum login!',
|
|
backgroundColor: Colors.red,
|
|
colorText: Colors.white,
|
|
);
|
|
return;
|
|
}
|
|
|
|
if (inputText.trim().isEmpty) {
|
|
Get.snackbar(
|
|
'Peringatan',
|
|
'Tidak ada teks untuk disimpan!',
|
|
backgroundColor: Colors.orange,
|
|
colorText: Colors.white,
|
|
);
|
|
return;
|
|
}
|
|
|
|
await _controller.saveResi(inputText.trim(), user.uid);
|
|
|
|
Get.snackbar(
|
|
'Berhasil',
|
|
'Data berhasil disimpan ke Firestore!',
|
|
backgroundColor: Colors.green,
|
|
colorText: Colors.white,
|
|
);
|
|
}
|
|
}
|