memperbaiki beberapa fitur

This commit is contained in:
rijalhabibullah 2026-05-14 03:49:04 +07:00
parent fd6ee27287
commit 6b792d779c
5 changed files with 40 additions and 12 deletions

View File

@ -35,7 +35,7 @@ class _LoginScreenState extends State<LoginScreen> {
try {
final response = await http
.post(
Uri.parse('http://192.168.18.23:8000/api/mobile/login'),
Uri.parse('http://192.168.43.222:8000/api/mobile/login'),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',

View File

@ -45,7 +45,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
try {
final response = await http
.post(
Uri.parse('http://192.168.18.23:8000/api/mobile/register'),
Uri.parse('http://192.168.43.222:8000/api/mobile/register'),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',

View File

@ -454,7 +454,7 @@ class _ResultScreenState extends State<ResultScreen> {
// Harga
Text(
'Rp ${product.price.toStringAsFixed(0)}',
'Rp ${_formatPrice(product.price)}',
style: const TextStyle(
fontSize: 11,
fontWeight: FontWeight.bold,
@ -498,14 +498,28 @@ class _ResultScreenState extends State<ResultScreen> {
}
Future<void> _launchUrl(String urlString) async {
final Uri url = Uri.parse(urlString);
final String trimmed = urlString.trim();
if (trimmed.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Link kosong')),
);
return;
}
final Uri? parsed = Uri.tryParse(trimmed);
final Uri url = (parsed != null && parsed.hasScheme)
? parsed
: Uri.parse('https://$trimmed');
try {
if (await canLaunchUrl(url)) {
await launchUrl(url, mode: LaunchMode.externalApplication);
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Tidak dapat membuka link')),
);
final bool opened = await launchUrl(url, mode: LaunchMode.externalApplication);
if (!opened) {
final bool fallbackOpened = await launchUrl(url, mode: LaunchMode.platformDefault);
if (!fallbackOpened) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Tidak dapat membuka link')),
);
}
}
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
@ -514,6 +528,20 @@ class _ResultScreenState extends State<ResultScreen> {
}
}
String _formatPrice(double price) {
final value = price.round();
final raw = value.toString();
final buffer = StringBuffer();
for (int i = 0; i < raw.length; i++) {
final position = raw.length - i;
buffer.write(raw[i]);
if (position > 1 && position % 3 == 1) {
buffer.write('.');
}
}
return buffer.toString();
}
void _showDetailPopup(BuildContext context) {
showDialog(
context: context,

View File

@ -10,7 +10,7 @@ class ClassificationService {
// Device Fisik (WiFi): http://192.168.x.x:8000/api/classification (ganti dengan IP komputer Anda)
// Testing Lokal: http://127.0.0.1:8000/api/classification
// Production (ngrok): https://gobony-wedgy-cathi.ngrok-free.dev/api/classification
static const String _apiRoot = 'http://192.168.18.23:8000/api';
static const String _apiRoot = 'https://gobony-wedgy-cathi.ngrok-free.dev/api';
static const String _baseUrl = '$_apiRoot/classification';
static const String _historyUrl = '$_apiRoot/classifications';

View File

@ -41,7 +41,7 @@ class ProductItem {
class ProductService {
// Samakan dengan API root di classification_service.dart
static const String _apiRoot = 'http://192.168.18.23:8000/api';
static const String _apiRoot = 'https://gobony-wedgy-cathi.ngrok-free.dev/api';
static const String _productsUrl = '$_apiRoot/products';
final http.Client _httpClient;