feat: add hold functionality and update keypad layout in CallPage
All checks were successful
/ mirror (push) Successful in 8s
/ build-stealth (push) Successful in 8m45s
/ build (push) Successful in 8m46s

This commit is contained in:
AlexisDanlos 2025-03-16 23:28:46 +01:00
parent fb5f155430
commit 06251183df

View File

@ -20,6 +20,7 @@ class _CallPageState extends State<CallPage> {
bool isKeypadVisible = false; bool isKeypadVisible = false;
bool icingProtocolOk = true; bool icingProtocolOk = true;
String _typedDigits = ""; // New state variable for pressed digits String _typedDigits = ""; // New state variable for pressed digits
bool isOnHold = false; // New state variable for hold status
void _addDigit(String digit) { void _addDigit(String digit) {
setState(() { setState(() {
@ -51,6 +52,12 @@ class _CallPageState extends State<CallPage> {
}); });
} }
void _toggleHold() {
setState(() {
isOnHold = !isOnHold;
});
}
void _hangUp() { void _hangUp() {
Navigator.pop(context); Navigator.pop(context);
} }
@ -121,11 +128,9 @@ class _CallPageState extends State<CallPage> {
Expanded( Expanded(
child: Column( child: Column(
children: [ children: [
if (isKeypadVisible) ...[ if (isKeypadVisible) ...
// Add spacer to push keypad down [
const Spacer(flex: 2), // Typed digits display remains the same
// Typed digits display
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0), padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Row( child: Row(
@ -153,50 +158,67 @@ class _CallPageState extends State<CallPage> {
), ),
), ),
// Keypad grid // Modified keypad section
Container( Container(
height: MediaQuery.of(context).size.height * 0.35, padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
margin: const EdgeInsets.symmetric(horizontal: 20), child: Column(
child: GridView.count( mainAxisSize: MainAxisSize.min,
shrinkWrap: true, children: [
physics: const NeverScrollableScrollPhysics(), for (var i = 0; i < 4; i++)
crossAxisCount: 3, Row(
childAspectRatio: 1.3, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSpacing: 8, children: [
crossAxisSpacing: 8, for (var j = 1; j <= 3; j++)
children: List.generate(12, (index) { Expanded(
String label; child: AspectRatio(
if (index < 9) { aspectRatio: 1.5,
label = '${index + 1}'; child: Padding(
} else if (index == 9) { padding: const EdgeInsets.all(4.0),
label = '*'; child: Material(
} else if (index == 10) {
label = '0';
} else {
label = '#';
}
return GestureDetector(
onTap: () => _addDigit(label),
child: Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.transparent, color: Colors.transparent,
child: InkWell(
customBorder: const CircleBorder(),
onTap: () {
String label;
if (i < 3) {
label = '${i * 3 + j}';
} else {
if (j == 1) label = '*';
else if (j == 2) label = '0';
else label = '#';
}
_addDigit(label);
},
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.grey[900]?.withOpacity(0.5),
), ),
child: Center( child: Center(
child: Text( child: Text(
label, i < 3 ? '${i * 3 + j}'
style: const TextStyle(fontSize: 32, color: Colors.white), : (j == 1 ? '*' : (j == 2 ? '0' : '#')),
style: const TextStyle(
fontSize: 32,
color: Colors.white,
), ),
), ),
), ),
); ),
}), ),
),
),
),
),
],
),
],
), ),
), ),
// Add spacer after keypad ] else ...
const Spacer(flex: 1), [
] else ...[ const Spacer(),
const Spacer(), const Spacer(),
// Control buttons // Control buttons
Padding( Padding(
@ -258,6 +280,7 @@ class _CallPageState extends State<CallPage> {
), ),
], ],
), ),
// New "mettre en attente" / Hold button
], ],
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
@ -279,6 +302,24 @@ class _CallPageState extends State<CallPage> {
style: TextStyle(color: Colors.white, fontSize: 14)), style: TextStyle(color: Colors.white, fontSize: 14)),
], ],
), ),
// New "Hold" button inserted between Add Contact and Change SIM
Column(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
onPressed: _toggleHold,
icon: Icon(
isOnHold ? Icons.play_arrow : Icons.pause,
color: Colors.white,
size: 32,
),
),
Text(
isOnHold ? 'Resume' : 'Hold',
style: const TextStyle(color: Colors.white, fontSize: 14),
),
],
),
// Change SIM // Change SIM
Column( Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,