feat(voice): unified mobile voice bar with gesture-isolated PTT row (#22)
* feat(voice): unified mobile voice bar with gesture-isolated PTT row Replace separate VoiceStatusChip + VoicePttButton with a single CompactVoiceBar widget that combines both into a two-row layout: - Control row (tap): status text, mute, deafen, settings chevron - PTT row (hold): full-width hold-to-talk, shown only in PTT mode Gesture isolation prevents mis-touch between rows: the control row uses tap-only InkWell/IconButton while the PTT row uses a raw Listener for pointer-down/up events. Key changes: - Add CompactVoiceBar widget with state-colored container (normal, muted, talk-power-blocked) - Remove mute/deafen IconButtons from AppBar headerActions - Restructure voice details sheet into primary section + collapsible ExpansionTiles (audio processing, PTT capability, debug) - Optimistic state updates for mute/deafen to eliminate tap delay - Instant PTT visual feedback (no AnimatedContainer fade) - Constant geometry across all states (no layout shift on toggle) * fix(voice): preserve current PTT button format * feat(voice): move mute/deafen controls into VoiceStatusChip * fix(voice): ensure consistent chip height across mute states Remove isSelected/selectedIcon from IconButtons inside VoiceStatusChip. Material 3 toggle IconButtons (_SelectableIconButton) can vary in height when the selected state changes due to tap target sizing. Use simple conditional icons instead and set shrinkWrap tap target size with tight constraints for stable 40x40 buttons regardless of state. * fix(voice): remove leftover duplicate mute/deafen buttons in VoiceStatusChip * fix(voice): replace unsafe stereo cast with bytemuck and localise talk-power tooltip Replace the raw-pointer `&mut [(f32, f32)]` to `&mut [f32]` cast in the oboe output callback with `bytemuck::cast_slice_mut`, eliminating the unsafe block and relying on bytemuck compile-time NoUninit verification instead. Add voiceTalkPowerBlocked l10n key (en + zh) and replace the only remaining hard-coded English tooltip in VoiceStatusChip with it.
This commit is contained in:
@@ -385,8 +385,7 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
// and Notifications permission service. On non-macOS hosts the service
|
||||
// short-circuits to "granted" / "unsupported" and never wires the
|
||||
// MethodChannel.
|
||||
final MacOSPermissionsService _macOSPermissions =
|
||||
MacOSPermissionsService();
|
||||
final MacOSPermissionsService _macOSPermissions = MacOSPermissionsService();
|
||||
final UiPreferencesService _uiPreferences = const UiPreferencesService();
|
||||
|
||||
@override
|
||||
@@ -677,7 +676,10 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
_reconnectDelay = null;
|
||||
});
|
||||
case rust.BridgeEvent_Reconnecting(:final attempt, :final delaySecs):
|
||||
_recordUiDiagnostic('connection', 'reconnecting attempt=$attempt delay=${delaySecs}s');
|
||||
_recordUiDiagnostic(
|
||||
'connection',
|
||||
'reconnecting attempt=$attempt delay=${delaySecs}s',
|
||||
);
|
||||
setState(() {
|
||||
_phase = ConnectionPhase.reconnecting;
|
||||
_reconnectAttempt = attempt;
|
||||
@@ -852,23 +854,41 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
);
|
||||
return updated;
|
||||
});
|
||||
case rust.BridgeEvent_ClientJoined(:final clientId, :final channelId, :final name, :final inputMuted, :final outputMuted, :final isServerQuery, :final talkPower, :final talkPowerGranted):
|
||||
case rust.BridgeEvent_ClientJoined(
|
||||
:final clientId,
|
||||
:final channelId,
|
||||
:final name,
|
||||
:final inputMuted,
|
||||
:final outputMuted,
|
||||
:final isServerQuery,
|
||||
:final talkPower,
|
||||
:final talkPowerGranted,
|
||||
):
|
||||
if (!isServerQuery) {
|
||||
_applyClientAdd(rust.BridgeClient(
|
||||
id: clientId,
|
||||
channel: channelId,
|
||||
name: name,
|
||||
inputMuted: inputMuted,
|
||||
outputMuted: outputMuted,
|
||||
isSpeaking: false,
|
||||
isServerQuery: isServerQuery,
|
||||
talkPower: talkPower,
|
||||
talkPowerGranted: talkPowerGranted,
|
||||
));
|
||||
_applyClientAdd(
|
||||
rust.BridgeClient(
|
||||
id: clientId,
|
||||
channel: channelId,
|
||||
name: name,
|
||||
inputMuted: inputMuted,
|
||||
outputMuted: outputMuted,
|
||||
isSpeaking: false,
|
||||
isServerQuery: isServerQuery,
|
||||
talkPower: talkPower,
|
||||
talkPowerGranted: talkPowerGranted,
|
||||
),
|
||||
);
|
||||
}
|
||||
case rust.BridgeEvent_ClientLeft(:final clientId):
|
||||
_applyClientRemove(clientId);
|
||||
case rust.BridgeEvent_ClientUpdated(:final clientId, :final inputMuted, :final outputMuted, :final isServerQuery, :final talkPower, :final talkPowerGranted):
|
||||
case rust.BridgeEvent_ClientUpdated(
|
||||
:final clientId,
|
||||
:final inputMuted,
|
||||
:final outputMuted,
|
||||
:final isServerQuery,
|
||||
:final talkPower,
|
||||
:final talkPowerGranted,
|
||||
):
|
||||
_applyClientDelta((c) => c.id == clientId, (c) {
|
||||
final updated = rust.BridgeClient(
|
||||
id: c.id,
|
||||
@@ -883,18 +903,32 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
);
|
||||
return updated;
|
||||
});
|
||||
case rust.BridgeEvent_ChannelAdded(:final id, :final parent, :final name, :final order, :final hasPassword, :final neededTalkPower):
|
||||
_applyChannelAdd(rust.BridgeChannel(
|
||||
id: id,
|
||||
parent: parent,
|
||||
name: name,
|
||||
order: order,
|
||||
hasPassword: hasPassword,
|
||||
neededTalkPower: neededTalkPower,
|
||||
));
|
||||
case rust.BridgeEvent_ChannelAdded(
|
||||
:final id,
|
||||
:final parent,
|
||||
:final name,
|
||||
:final order,
|
||||
:final hasPassword,
|
||||
:final neededTalkPower,
|
||||
):
|
||||
_applyChannelAdd(
|
||||
rust.BridgeChannel(
|
||||
id: id,
|
||||
parent: parent,
|
||||
name: name,
|
||||
order: order,
|
||||
hasPassword: hasPassword,
|
||||
neededTalkPower: neededTalkPower,
|
||||
),
|
||||
);
|
||||
case rust.BridgeEvent_ChannelRemoved(:final id):
|
||||
_applyChannelRemove(id);
|
||||
case rust.BridgeEvent_ChannelUpdated(:final id, :final name, :final hasPassword, :final neededTalkPower):
|
||||
case rust.BridgeEvent_ChannelUpdated(
|
||||
:final id,
|
||||
:final name,
|
||||
:final hasPassword,
|
||||
:final neededTalkPower,
|
||||
):
|
||||
_applyChannelDelta((ch) => ch.id == id, (ch) {
|
||||
return rust.BridgeChannel(
|
||||
id: ch.id,
|
||||
@@ -932,7 +966,8 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
final now = DateTime.now();
|
||||
if (_inChannel &&
|
||||
(_lastSpeakingRefresh == null ||
|
||||
now.difference(_lastSpeakingRefresh!) >= _speakingRefreshInterval)) {
|
||||
now.difference(_lastSpeakingRefresh!) >=
|
||||
_speakingRefreshInterval)) {
|
||||
_lastSpeakingRefresh = now;
|
||||
unawaited(_refreshSnapshot(recordActivity: false, reportErrors: false));
|
||||
}
|
||||
@@ -1134,14 +1169,16 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
|
||||
Future<void> _toggleOutputMute() async {
|
||||
final next = !_outputMuted;
|
||||
setState(() {
|
||||
_outputMuted = next;
|
||||
});
|
||||
try {
|
||||
await rust.setOutputMuted(muted: next);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_outputMuted = next;
|
||||
});
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_outputMuted = !next;
|
||||
});
|
||||
_showUiError('output mute', e);
|
||||
}
|
||||
}
|
||||
@@ -1268,6 +1305,16 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
return;
|
||||
}
|
||||
final next = !_hardMute;
|
||||
final previousInputMuted = _inputMuted;
|
||||
final previousHardMute = _hardMute;
|
||||
final previousPermissionMute = _hardMuteByPermission;
|
||||
setState(() {
|
||||
_inputMuted = next;
|
||||
_hardMute = next;
|
||||
if (next) {
|
||||
_hardMuteByPermission = false;
|
||||
}
|
||||
});
|
||||
try {
|
||||
// Hard-mute is two coordinated effects:
|
||||
// * setHardMute — local TransmitGate clamp; we stop sending
|
||||
@@ -1280,14 +1327,13 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
// through. Drive them together.
|
||||
await rust.setHardMute(muted: next);
|
||||
await rust.setInputMuted(muted: next);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_inputMuted = next;
|
||||
_hardMute = next;
|
||||
_hardMuteByPermission = false;
|
||||
});
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_inputMuted = previousInputMuted;
|
||||
_hardMute = previousHardMute;
|
||||
_hardMuteByPermission = previousPermissionMute;
|
||||
});
|
||||
_showUiError('hard mute', e);
|
||||
}
|
||||
}
|
||||
@@ -1745,7 +1791,10 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
};
|
||||
}
|
||||
|
||||
void _applyClientDelta(bool Function(rust.BridgeClient) test, rust.BridgeClient Function(rust.BridgeClient) update) {
|
||||
void _applyClientDelta(
|
||||
bool Function(rust.BridgeClient) test,
|
||||
rust.BridgeClient Function(rust.BridgeClient) update,
|
||||
) {
|
||||
final snap = _snapshot;
|
||||
if (snap == null) return;
|
||||
final clients = snap.clients.map((c) => test(c) ? update(c) : c).toList();
|
||||
@@ -1831,10 +1880,15 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
});
|
||||
}
|
||||
|
||||
void _applyChannelDelta(bool Function(rust.BridgeChannel) test, rust.BridgeChannel Function(rust.BridgeChannel) update) {
|
||||
void _applyChannelDelta(
|
||||
bool Function(rust.BridgeChannel) test,
|
||||
rust.BridgeChannel Function(rust.BridgeChannel) update,
|
||||
) {
|
||||
final snap = _snapshot;
|
||||
if (snap == null) return;
|
||||
final channels = snap.channels.map((ch) => test(ch) ? update(ch) : ch).toList();
|
||||
final channels = snap.channels
|
||||
.map((ch) => test(ch) ? update(ch) : ch)
|
||||
.toList();
|
||||
setState(() {
|
||||
_snapshot = rust.BridgeSnapshot(
|
||||
serverName: snap.serverName,
|
||||
@@ -2153,26 +2207,6 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
final headerActions = [
|
||||
if (_serverReachable && _inChannel) ...[
|
||||
IconButton(
|
||||
tooltip: _hardMuteByTalkPower
|
||||
? 'Insufficient talk power to speak in this channel'
|
||||
: l10n.voiceHardMuteLabel,
|
||||
icon: Icon(_hardMute ? Icons.mic_off : Icons.mic),
|
||||
isSelected: _hardMute,
|
||||
selectedIcon: const Icon(Icons.mic_off),
|
||||
color: _hardMute ? theme.colorScheme.error : null,
|
||||
onPressed: _hardMuteByTalkPower ? null : _onToggleHardMute,
|
||||
),
|
||||
IconButton(
|
||||
tooltip: l10n.voiceOutputMuteLabel,
|
||||
icon: Icon(_outputMuted ? Icons.headset_off : Icons.headset),
|
||||
isSelected: _outputMuted,
|
||||
selectedIcon: const Icon(Icons.headset_off),
|
||||
color: _outputMuted ? theme.colorScheme.error : null,
|
||||
onPressed: _toggleOutputMute,
|
||||
),
|
||||
],
|
||||
IconButton(
|
||||
tooltip: l10n.aboutAction,
|
||||
icon: const Icon(Icons.info_outline),
|
||||
@@ -2466,10 +2500,13 @@ class _BetaHomeState extends State<_BetaHome> with WidgetsBindingObserver {
|
||||
isTouchOnly: isTouchOnlyPttHost,
|
||||
inputMuted: _hardMute,
|
||||
outputMuted: _outputMuted,
|
||||
hardMuteByTalkPower: _hardMuteByTalkPower,
|
||||
talkPower: ownClientState?.talkPower,
|
||||
neededTalkPower: ownClientState?.neededTalkPower,
|
||||
talkPowerGranted: ownClientState?.talkPowerGranted,
|
||||
onTap: () => _onOpenVoiceDetailsSheet(),
|
||||
onToggleInputMute: _onToggleHardMute,
|
||||
onToggleOutputMute: _toggleOutputMute,
|
||||
),
|
||||
if (_inChannel &&
|
||||
_transmitMode == rust.BridgeTransmitMode.ptt) ...[
|
||||
|
||||
Reference in New Issue
Block a user