Fix Telegram viewport and SVG avatars
All checks were successful
Build and deploy Flutter Web / build (push) Successful in 2m48s

This commit is contained in:
Ruslan Bakiev
2026-05-13 22:50:51 +07:00
parent d3721e44e7
commit cdf6a43d49
6 changed files with 105 additions and 21 deletions

View File

@@ -4,6 +4,7 @@ import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:latlong2/latlong.dart' hide Path;
import 'package:waveform_flutter/waveform_flutter.dart' show Amplitude;
import 'package:waveform_recorder/waveform_recorder.dart';
@@ -231,11 +232,7 @@ class _UserAvatar extends StatelessWidget {
dimension: 44,
child: imageUrl == null
? _AvatarFallback(text: fallback)
: Image.network(
imageUrl,
fit: BoxFit.cover,
errorBuilder: (_, _, _) => _AvatarFallback(text: fallback),
),
: _AvatarImage(url: imageUrl, fallback: fallback),
),
),
),
@@ -264,6 +261,31 @@ class _UserAvatar extends StatelessWidget {
enum _AvatarAction { logout }
class _AvatarImage extends StatelessWidget {
const _AvatarImage({required this.url, required this.fallback});
final String url;
final String fallback;
@override
Widget build(BuildContext context) {
if (url.endsWith('.svg') || url.contains('.svg?')) {
return SvgPicture.network(
url,
fit: BoxFit.cover,
placeholderBuilder: (_) => _AvatarFallback(text: fallback),
errorBuilder: (_, _, _) => _AvatarFallback(text: fallback),
);
}
return Image.network(
url,
fit: BoxFit.cover,
errorBuilder: (_, _, _) => _AvatarFallback(text: fallback),
);
}
}
class _AvatarFallback extends StatelessWidget {
const _AvatarFallback({required this.text});
@@ -1004,12 +1026,6 @@ class _NearbyPlaceCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final primaryType = _formatType(place.googlePrimaryType);
final visibleTypes = place.googleTypes
.where((type) => type != place.googlePrimaryType)
.map(_formatType)
.nonNulls
.take(4)
.toList();
return Material(
color: const Color(0xFF15111D),
@@ -1041,17 +1057,12 @@ class _NearbyPlaceCard extends StatelessWidget {
),
],
),
if (primaryType != null || visibleTypes.isNotEmpty) ...[
if (primaryType != null) ...[
const SizedBox(height: 12),
Wrap(
spacing: 6,
runSpacing: 6,
children: [
if (primaryType != null)
_PlaceTypeChip(label: primaryType, primary: true),
for (final type in visibleTypes)
_PlaceTypeChip(label: type, primary: false),
],
children: [_PlaceTypeChip(label: primaryType, primary: true)],
),
],
],