monorepo/dialer/lib/presentation/features/settings/sim/settings_sim.dart

65 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class SettingsSimPage extends StatefulWidget {
const SettingsSimPage({super.key});
@override
_SettingsSimPageState createState() => _SettingsSimPageState();
}
class _SettingsSimPageState extends State<SettingsSimPage> {
int _selectedSim = 0;
@override
void initState() {
super.initState();
_loadDefaultSim();
}
void _loadDefaultSim() async {
final prefs = await SharedPreferences.getInstance();
setState(() {
_selectedSim = prefs.getInt('default_sim_slot') ?? 0;
});
}
void _onSimChanged(int? value) async {
if (value != null) {
final prefs = await SharedPreferences.getInstance();
await prefs.setInt('default_sim_slot', value);
setState(() {
_selectedSim = value;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: const Text('Default SIM'),
),
body: ListView(
children: [
RadioListTile<int>(
title: const Text('SIM 1', style: TextStyle(color: Colors.white)),
value: 0,
groupValue: _selectedSim,
onChanged: _onSimChanged,
activeColor: Colors.blue,
),
RadioListTile<int>(
title: const Text('SIM 2', style: TextStyle(color: Colors.white)),
value: 1,
groupValue: _selectedSim,
onChanged: _onSimChanged,
activeColor: Colors.blue,
),
],
),
);
}
}