feat: implement dynamic width for typed digits display in CallPage
This commit is contained in:
parent
06251183df
commit
97d6a3200b
@ -68,6 +68,22 @@ class _CallPageState extends State<CallPage> {
|
|||||||
final double nameFontSize = isKeypadVisible ? 24.0 : 24.0; // Smaller font
|
final double nameFontSize = isKeypadVisible ? 24.0 : 24.0; // Smaller font
|
||||||
final double statusFontSize = isKeypadVisible ? 16.0 : 16.0; // Smaller status
|
final double statusFontSize = isKeypadVisible ? 16.0 : 16.0; // Smaller status
|
||||||
|
|
||||||
|
// Calculate max visible chars based on screen width
|
||||||
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
// Estimate ~14 pixels per character for the digit display (fontSize 24)
|
||||||
|
// Subtract some padding (40) for the margins
|
||||||
|
int estimatedMaxChars = ((screenWidth - 80) ~/ 14).clamp(10, 100) - 1;
|
||||||
|
|
||||||
|
// Helper function to format the displayed digits with dynamic width
|
||||||
|
String _formatDisplayDigits() {
|
||||||
|
if (_typedDigits.length <= estimatedMaxChars) {
|
||||||
|
return _typedDigits;
|
||||||
|
} else {
|
||||||
|
// Show ellipsis at the beginning and the most recent digits
|
||||||
|
return '...' + _typedDigits.substring(_typedDigits.length - estimatedMaxChars + 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Container(
|
body: Container(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
@ -130,7 +146,7 @@ class _CallPageState extends State<CallPage> {
|
|||||||
children: [
|
children: [
|
||||||
if (isKeypadVisible) ...
|
if (isKeypadVisible) ...
|
||||||
[
|
[
|
||||||
// Typed digits display remains the same
|
// Updated typed digits display with dynamic width
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -138,10 +154,10 @@ class _CallPageState extends State<CallPage> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
_typedDigits,
|
_formatDisplayDigits(),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.visible,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
Loading…
Reference in New Issue
Block a user