memperbaiki beberapa fitur
This commit is contained in:
parent
fd6ee27287
commit
6b792d779c
|
|
@ -35,7 +35,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
try {
|
try {
|
||||||
final response = await http
|
final response = await http
|
||||||
.post(
|
.post(
|
||||||
Uri.parse('http://192.168.18.23:8000/api/mobile/login'),
|
Uri.parse('http://192.168.43.222:8000/api/mobile/login'),
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||||
try {
|
try {
|
||||||
final response = await http
|
final response = await http
|
||||||
.post(
|
.post(
|
||||||
Uri.parse('http://192.168.18.23:8000/api/mobile/register'),
|
Uri.parse('http://192.168.43.222:8000/api/mobile/register'),
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
|
||||||
|
|
@ -454,7 +454,7 @@ class _ResultScreenState extends State<ResultScreen> {
|
||||||
|
|
||||||
// Harga
|
// Harga
|
||||||
Text(
|
Text(
|
||||||
'Rp ${product.price.toStringAsFixed(0)}',
|
'Rp ${_formatPrice(product.price)}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
|
@ -498,15 +498,29 @@ class _ResultScreenState extends State<ResultScreen> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _launchUrl(String urlString) async {
|
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 {
|
try {
|
||||||
if (await canLaunchUrl(url)) {
|
final bool opened = await launchUrl(url, mode: LaunchMode.externalApplication);
|
||||||
await launchUrl(url, mode: LaunchMode.externalApplication);
|
if (!opened) {
|
||||||
} else {
|
final bool fallbackOpened = await launchUrl(url, mode: LaunchMode.platformDefault);
|
||||||
|
if (!fallbackOpened) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Tidak dapat membuka link')),
|
const SnackBar(content: Text('Tidak dapat membuka link')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('Error: $e')),
|
SnackBar(content: Text('Error: $e')),
|
||||||
|
|
@ -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) {
|
void _showDetailPopup(BuildContext context) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class ClassificationService {
|
||||||
// Device Fisik (WiFi): http://192.168.x.x:8000/api/classification (ganti dengan IP komputer Anda)
|
// 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
|
// Testing Lokal: http://127.0.0.1:8000/api/classification
|
||||||
// Production (ngrok): https://gobony-wedgy-cathi.ngrok-free.dev/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 _baseUrl = '$_apiRoot/classification';
|
||||||
static const String _historyUrl = '$_apiRoot/classifications';
|
static const String _historyUrl = '$_apiRoot/classifications';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class ProductItem {
|
||||||
|
|
||||||
class ProductService {
|
class ProductService {
|
||||||
// Samakan dengan API root di classification_service.dart
|
// 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';
|
static const String _productsUrl = '$_apiRoot/products';
|
||||||
|
|
||||||
final http.Client _httpClient;
|
final http.Client _httpClient;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue