domingo
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/pages/PlacarPage.dart';
|
||||
import 'package:playmaker/classe/theme.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart'; // 👇 A MAGIA DO CACHE AQUI
|
||||
import '../controllers/team_controller.dart';
|
||||
import '../controllers/game_controller.dart';
|
||||
import '../models/game_model.dart';
|
||||
@@ -43,14 +44,31 @@ class GameResultCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// 👇 AVATAR OTIMIZADO COM CACHE 👇
|
||||
Widget _buildTeamInfo(String name, Color color, String? logoUrl, double sf, Color textColor) {
|
||||
final double avatarSize = 48 * sf; // 2 * radius (24)
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 24 * sf,
|
||||
backgroundColor: color,
|
||||
backgroundImage: (logoUrl != null && logoUrl.isNotEmpty) ? NetworkImage(logoUrl) : null,
|
||||
child: (logoUrl == null || logoUrl.isEmpty) ? Icon(Icons.shield, color: Colors.white, size: 24 * sf) : null,
|
||||
ClipOval(
|
||||
child: Container(
|
||||
width: avatarSize,
|
||||
height: avatarSize,
|
||||
color: color.withOpacity(0.1), // Fundo suave para não ser agressivo
|
||||
child: (logoUrl != null && logoUrl.isNotEmpty)
|
||||
? CachedNetworkImage(
|
||||
imageUrl: logoUrl,
|
||||
fit: BoxFit.cover,
|
||||
fadeInDuration: Duration.zero, // Fica instantâneo
|
||||
placeholder: (context, url) => Center(
|
||||
child: Icon(Icons.shield, color: color, size: 24 * sf)
|
||||
),
|
||||
errorWidget: (context, url, error) => Center(
|
||||
child: Icon(Icons.shield, color: color, size: 24 * sf)
|
||||
),
|
||||
)
|
||||
: Center(child: Icon(Icons.shield, color: color, size: 24 * sf)),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6 * sf),
|
||||
Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13 * sf, color: textColor), textAlign: TextAlign.center, overflow: TextOverflow.ellipsis, maxLines: 2),
|
||||
@@ -161,6 +179,7 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
);
|
||||
}
|
||||
|
||||
// 👇 PESQUISA COM CACHE 👇
|
||||
Widget _buildSearch(BuildContext context, String label, TextEditingController controller) {
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: widget.teamController.teamsStream,
|
||||
@@ -188,7 +207,22 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
final String name = option['name'].toString();
|
||||
final String? imageUrl = option['image_url'];
|
||||
return ListTile(
|
||||
leading: CircleAvatar(radius: 20 * widget.sf, backgroundColor: Colors.grey.withOpacity(0.2), backgroundImage: (imageUrl != null && imageUrl.isNotEmpty) ? NetworkImage(imageUrl) : null, child: (imageUrl == null || imageUrl.isEmpty) ? Icon(Icons.shield, color: Colors.grey, size: 20 * widget.sf) : null),
|
||||
leading: ClipOval(
|
||||
child: Container(
|
||||
width: 40 * widget.sf,
|
||||
height: 40 * widget.sf,
|
||||
color: Colors.grey.withOpacity(0.2),
|
||||
child: (imageUrl != null && imageUrl.isNotEmpty)
|
||||
? CachedNetworkImage(
|
||||
imageUrl: imageUrl,
|
||||
fit: BoxFit.cover,
|
||||
fadeInDuration: Duration.zero,
|
||||
placeholder: (context, url) => Icon(Icons.shield, color: Colors.grey, size: 20 * widget.sf),
|
||||
errorWidget: (context, url, error) => Icon(Icons.shield, color: Colors.grey, size: 20 * widget.sf),
|
||||
)
|
||||
: Icon(Icons.shield, color: Colors.grey, size: 20 * widget.sf),
|
||||
),
|
||||
),
|
||||
title: Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14 * widget.sf, color: Theme.of(context).colorScheme.onSurface)),
|
||||
onTap: () { onSelected(option); },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user