mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-15 07:04:26 +10:00
fa044dd204
- Introduced new dialog messages for connecting to a companion and handling disconnection across multiple languages. - Updated localization files for French, Hungarian, Italian, Japanese, Korean, Bulgarian, German, English, Spanish, Dutch, Polish, Portuguese, Russian, Slovak, Slovenian, Swedish, Ukrainian, and Chinese. - Modified the contacts and map screens to utilize the new dialog messages. - Enhanced the disconnect confirmation dialog to show a message upon successful disconnection. - Updated app bar to conditionally display radio stats based on companion connection status.
83 lines
2.7 KiB
Dart
83 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:meshcore_open/connector/meshcore_connector.dart';
|
|
import 'package:meshcore_open/widgets/battery_indicator.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'radio_stats_entry.dart';
|
|
import 'snr_indicator.dart';
|
|
|
|
class AppBarTitle extends StatelessWidget {
|
|
final String title;
|
|
final Widget? leading;
|
|
final Widget? trailing;
|
|
final bool indicators;
|
|
final bool showBatteryIndicator;
|
|
final bool subtitle;
|
|
const AppBarTitle(
|
|
this.title, {
|
|
this.leading,
|
|
this.trailing,
|
|
this.indicators = true,
|
|
this.showBatteryIndicator = true,
|
|
this.subtitle = true,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final connector = context.watch<MeshCoreConnector>();
|
|
final selfName = connector.selfName;
|
|
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final availableWidth = constraints.hasBoundedWidth
|
|
? constraints.maxWidth
|
|
: MediaQuery.sizeOf(context).width;
|
|
final compact = availableWidth < 170;
|
|
final showSubtitle =
|
|
!compact && connector.isConnected && selfName != null && subtitle;
|
|
final showBattery = showBatteryIndicator && availableWidth >= 60;
|
|
final showSnr = availableWidth >= 110;
|
|
final showIndicators = (showBattery || showSnr) && indicators;
|
|
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
leading ?? const SizedBox.shrink(),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(title, maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
if (showSubtitle)
|
|
Text(
|
|
selfName,
|
|
style: TextStyle(fontSize: 14, color: Colors.grey[600]),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (showIndicators) const SizedBox(width: 6),
|
|
if (showIndicators)
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (showBattery) BatteryIndicator(connector: connector),
|
|
if (showSnr) SNRIndicator(connector: connector),
|
|
if (connector.supportsCompanionRadioStats)
|
|
if (connector.isConnected)
|
|
const RadioStatsIconButton(compact: true),
|
|
],
|
|
),
|
|
trailing ?? const SizedBox.shrink(),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|