fix(control-panel): prevent device name from overlapping header logo

This commit is contained in:
2026-04-26 08:52:13 +02:00
parent 6d2d16d8cb
commit 105211e334

View File

@@ -50,10 +50,7 @@ class ControlPanelScreen extends ConsumerWidget {
child: Column(
children: [
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 4)),
_Header(
state: state,
navigationContract: navigationContract,
),
_Header(state: state, navigationContract: navigationContract),
SizedBox(height: SizeUtils.getByScreen(small: 12, big: 14)),
Expanded(
child: RefreshIndicator(
@@ -102,33 +99,45 @@ class _Header extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(legacyDeviceViewModelProvider.notifier);
return Stack(
alignment: Alignment.center,
children: [
Padding(
padding: EdgeInsets.only(
top: SizeUtils.getByScreen(small: 14, big: 14),
),
child: Row(
children: [
Image.asset(
'assets/shared/images/iso_sf.png',
height: SizeUtils.getByScreen(small: 18, big: 18),
return Padding(
padding: EdgeInsets.only(top: SizeUtils.getByScreen(small: 14, big: 14)),
child: SizedBox(
height: SizeUtils.getByScreen(small: 36, big: 36),
child: Stack(
alignment: Alignment.center,
children: [
Center(
child: SvgPicture.asset(
'assets/shared/images/logo_sf.svg',
height: SizeUtils.getByScreen(small: 36, big: 36),
),
SizedBox(width: SizeUtils.getByScreen(small: 8, big: 4)),
_DeviceDropdown(
devices: state.devices,
selectedDevice: state.selectedDevice,
onChanged: vm.setSelectedDevice,
),
Align(
alignment: const Alignment(-1.0, 0.8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
'assets/shared/images/iso_sf.png',
height: SizeUtils.getByScreen(small: 18, big: 18),
),
SizedBox(width: SizeUtils.getByScreen(small: 8, big: 4)),
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 0.23,
),
child: _DeviceDropdown(
devices: state.devices,
selectedDevice: state.selectedDevice,
onChanged: vm.setSelectedDevice,
),
),
],
),
],
),
),
],
),
SvgPicture.asset(
'assets/shared/images/logo_sf.svg',
height: SizeUtils.getByScreen(small: 36, big: 36),
),
],
),
);
}
}
@@ -199,7 +208,6 @@ class _SectionButton extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
return SectionButton(
onPressed: onPressed,
icon: Icon(
@@ -224,10 +232,7 @@ class _MapSection extends ConsumerWidget {
final LegacyDeviceViewState state;
final NavigationContract navigationContract;
const _MapSection({
required this.state,
required this.navigationContract,
});
const _MapSection({required this.state, required this.navigationContract});
@override
Widget build(BuildContext context, WidgetRef ref) {
@@ -254,10 +259,7 @@ class _MapSection extends ConsumerWidget {
try {
await vm.refreshPositions();
if (!context.mounted) return;
await showSuccessDialog(
context,
I18n.positionUpdated,
);
await showSuccessDialog(context, I18n.positionUpdated);
} catch (e) {
if (!context.mounted) return;
await showErrorDialog(context, I18n.errorPositions);
@@ -369,8 +371,7 @@ class _DeviceDropdownState extends State<_DeviceDropdown>
child: FadeTransition(
opacity: _curve,
child: ScaleTransition(
scale: Tween<double>(begin: 0.92, end: 1.0)
.animate(_curve),
scale: Tween<double>(begin: 0.92, end: 1.0).animate(_curve),
alignment: Alignment.topLeft,
child: Material(
elevation: 4,
@@ -401,9 +402,9 @@ class _DeviceDropdownState extends State<_DeviceDropdown>
color: isSelected
? primaryColor
: Theme.of(context)
.colorScheme
.onSurface
.withValues(alpha: 0.4),
.colorScheme
.onSurface
.withValues(alpha: 0.4),
),
const SizedBox(width: 8),
Text(
@@ -415,9 +416,9 @@ class _DeviceDropdownState extends State<_DeviceDropdown>
: FontWeight.w400,
color: isSelected
? primaryColor
: Theme.of(context)
.colorScheme
.onSurface,
: Theme.of(
context,
).colorScheme.onSurface,
),
),
],
@@ -437,41 +438,35 @@ class _DeviceDropdownState extends State<_DeviceDropdown>
),
child: GestureDetector(
onTap: widget.devices.length > 1 ? _toggle : null,
child: SizedBox(
height: 32,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: SizeUtils.getByScreen(small: 100, big: 110),
),
child: Text(
selectedName,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 12, big: 13),
fontWeight: FontWeight.w600,
color: primaryColor,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Text(
selectedName,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 12, big: 13),
fontWeight: FontWeight.w600,
color: primaryColor,
),
),
if (widget.devices.length > 1)
AnimatedBuilder(
animation: _animation,
builder: (context, child) => Transform.rotate(
angle: _curve.value * 3.14159,
child: child,
),
child: Icon(
Icons.keyboard_arrow_down,
size: 18,
color: primaryColor,
),
),
if (widget.devices.length > 1)
AnimatedBuilder(
animation: _animation,
builder: (context, child) => Transform.rotate(
angle: _curve.value * 3.14159,
child: child,
),
],
),
child: Icon(
Icons.keyboard_arrow_down,
size: 18,
color: primaryColor,
),
),
],
),
),
),