|
|
|
|
@ -21,6 +21,7 @@ class SettingsScreen extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _SettingsScreenState extends State<SettingsScreen> {
|
|
|
|
|
bool _showBatteryVoltage = false;
|
|
|
|
|
bool _deviceInfoExpanded = false;
|
|
|
|
|
String _appVersion = '';
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -74,43 +75,84 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|
|
|
|
MeshCoreConnector connector,
|
|
|
|
|
) {
|
|
|
|
|
final l10n = context.l10n;
|
|
|
|
|
|
|
|
|
|
return Card(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
l10n.settings_deviceInfo,
|
|
|
|
|
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
_buildInfoRow(l10n.settings_infoName, connector.deviceDisplayName),
|
|
|
|
|
_buildInfoRow(l10n.settings_infoId, connector.deviceIdLabel),
|
|
|
|
|
_buildInfoRow(
|
|
|
|
|
l10n.settings_infoStatus,
|
|
|
|
|
connector.isConnected
|
|
|
|
|
? l10n.common_connected
|
|
|
|
|
: l10n.common_disconnected,
|
|
|
|
|
),
|
|
|
|
|
_buildBatteryInfoRow(context, connector),
|
|
|
|
|
if (connector.selfName != null)
|
|
|
|
|
_buildInfoRow(l10n.settings_nodeName, connector.selfName!),
|
|
|
|
|
if (connector.selfPublicKey != null)
|
|
|
|
|
_buildInfoRow(
|
|
|
|
|
l10n.settings_infoPublicKey,
|
|
|
|
|
'${pubKeyToHex(connector.selfPublicKey!).substring(0, 16)}...',
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
InkWell(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
onTap: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_deviceInfoExpanded = !_deviceInfoExpanded;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 16, 16, 16),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
l10n.settings_deviceInfo,
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
AnimatedRotation(
|
|
|
|
|
turns: _deviceInfoExpanded ? 0.5 : 0,
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
child: const Icon(Icons.expand_more),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
_buildInfoRow(
|
|
|
|
|
l10n.settings_infoContactsCount,
|
|
|
|
|
'${connector.contacts.length}',
|
|
|
|
|
),
|
|
|
|
|
_buildInfoRow(
|
|
|
|
|
l10n.settings_infoChannelCount,
|
|
|
|
|
'${connector.channels.length}',
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
AnimatedCrossFade(
|
|
|
|
|
firstChild: const SizedBox.shrink(),
|
|
|
|
|
secondChild: Padding(
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
_buildInfoRow(
|
|
|
|
|
l10n.settings_infoName,
|
|
|
|
|
connector.deviceDisplayName,
|
|
|
|
|
),
|
|
|
|
|
_buildInfoRow(l10n.settings_infoId, connector.deviceIdLabel),
|
|
|
|
|
_buildInfoRow(
|
|
|
|
|
l10n.settings_infoStatus,
|
|
|
|
|
connector.isConnected
|
|
|
|
|
? l10n.common_connected
|
|
|
|
|
: l10n.common_disconnected,
|
|
|
|
|
),
|
|
|
|
|
_buildBatteryInfoRow(context, connector),
|
|
|
|
|
if (connector.selfName != null)
|
|
|
|
|
_buildInfoRow(l10n.settings_nodeName, connector.selfName!),
|
|
|
|
|
if (connector.selfPublicKey != null)
|
|
|
|
|
_buildInfoRow(
|
|
|
|
|
l10n.settings_infoPublicKey,
|
|
|
|
|
'${pubKeyToHex(connector.selfPublicKey!).substring(0, 16)}...',
|
|
|
|
|
),
|
|
|
|
|
_buildInfoRow(
|
|
|
|
|
l10n.settings_infoContactsCount,
|
|
|
|
|
'${connector.contacts.length}',
|
|
|
|
|
),
|
|
|
|
|
_buildInfoRow(
|
|
|
|
|
l10n.settings_infoChannelCount,
|
|
|
|
|
'${connector.channels.length}',
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
crossFadeState: _deviceInfoExpanded
|
|
|
|
|
? CrossFadeState.showSecond
|
|
|
|
|
: CrossFadeState.showFirst,
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -355,22 +397,33 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|
|
|
|
Color? valueColor,
|
|
|
|
|
VoidCallback? onTap,
|
|
|
|
|
}) {
|
|
|
|
|
final theme = Theme.of(context);
|
|
|
|
|
|
|
|
|
|
final row = Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
if (leading != null) ...[leading, const SizedBox(width: 8)],
|
|
|
|
|
Text(label, style: TextStyle(color: Colors.grey[600])),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
label,
|
|
|
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
|
|
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Flexible(
|
|
|
|
|
child: Text(
|
|
|
|
|
value,
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w500, color: valueColor),
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
Text(
|
|
|
|
|
value,
|
|
|
|
|
style: theme.textTheme.bodyLarge?.copyWith(
|
|
|
|
|
color: valueColor,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -379,11 +432,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|
|
|
|
|
|
|
|
|
if (onTap != null) {
|
|
|
|
|
return InkWell(
|
|
|
|
|
borderRadius: BorderRadius.circular(6),
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
borderRadius: BorderRadius.circular(4),
|
|
|
|
|
child: row,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|