import 'package:shared_preferences/shared_preferences.dart';

class AppConfig {
  static String _ip = "192.168.1.4"; // IP Default
  static String _port = "8000";

  static String get baseUrl => "http://$_ip:$_port/api";
  static String get rawIp => _ip;

  // Memuat IP dari penyimpanan HP
  static Future<void> loadConfig() async {
    final prefs = await SharedPreferences.getInstance();
    _ip = prefs.getString('server_ip') ?? _ip;
    _port = prefs.getString('server_port') ?? _port;
  }

  // Menyimpan IP baru ke HP
  static Future<void> setIp(String newIp) async {
    _ip = newIp;
    final prefs = await SharedPreferences.getInstance();
    await prefs.setString('server_ip', newIp);
  }
}
