118 lines
3.8 KiB
Dart
118 lines
3.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_common/utils/date_utils.dart';
|
|
import 'package:food_hub_app/config/app_config.dart';
|
|
import 'package:food_hub_app/models/session.dart';
|
|
import 'package:food_hub_app/widgets/common/index.dart';
|
|
import 'package:liquid_glass_widgets/liquid_glass_widgets.dart';
|
|
import 'package:liquid_glass_widgets/widgets/containers/glass_card.dart';
|
|
|
|
class ProfileInfo extends StatelessWidget {
|
|
final User user;
|
|
|
|
const ProfileInfo({super.key, required this.user});
|
|
|
|
Widget _buildAvatar(BuildContext context, User user) {
|
|
if (user.avatar == null) {
|
|
return CircleAvatar(
|
|
radius: 24,
|
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
|
foregroundColor: Theme.of(context).colorScheme.surface,
|
|
child: Text(
|
|
user.username.isNotEmpty ? user.username[0] : '?',
|
|
style: TextStyle(fontSize: 14),
|
|
),
|
|
);
|
|
} else {
|
|
return CircleAvatar(
|
|
radius: 24,
|
|
backgroundImage: NetworkImage(
|
|
'${AppConfig.imageBaseUrl}/${user.avatar}',
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
Widget _buildInfoItem({
|
|
required BuildContext context,
|
|
required IconData icon,
|
|
required String text,
|
|
}) {
|
|
final colors = Theme.of(context).colorScheme;
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(icon, size: 16, color: colors.primary),
|
|
const SizedBox(width: 6),
|
|
Text(text, style: Theme.of(context).textTheme.bodySmall),
|
|
],
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colors = Theme.of(context).colorScheme;
|
|
|
|
return GlassCard(
|
|
padding: EdgeInsetsGeometry.all(10),
|
|
useOwnLayer: true,
|
|
settings: LiquidGlassSettings(glassColor: colors.surface),
|
|
child: Column(
|
|
children: [
|
|
_buildAvatar(context, user),
|
|
const SizedBox(height: 8),
|
|
Text(user.username, style: Theme.of(context).textTheme.titleMedium),
|
|
const SizedBox(height: 8),
|
|
if (user.tags != null && user.tags!.isNotEmpty)
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children:
|
|
user.tags!.map((tag) => buildTag(context, tag)).toList(),
|
|
),
|
|
if (user.tags != null && user.tags!.isNotEmpty)
|
|
const SizedBox(height: 8),
|
|
Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: [
|
|
if (user.area != null && user.area!.length >= 2)
|
|
_buildInfoItem(
|
|
context: context,
|
|
icon: Icons.location_on,
|
|
text: '${user.area![0]}-${user.area![1]}',
|
|
),
|
|
if (user.birthDate != null)
|
|
_buildInfoItem(
|
|
context: context,
|
|
icon: Icons.cake,
|
|
text: formatDate(user.birthDate!),
|
|
),
|
|
if (user.job != null && user.job!.isNotEmpty)
|
|
_buildInfoItem(
|
|
context: context,
|
|
icon: Icons.work,
|
|
text: user.job!,
|
|
),
|
|
if (user.phoneNumber != null && user.phoneNumber!.isNotEmpty)
|
|
_buildInfoItem(
|
|
context: context,
|
|
icon: Icons.phone_android,
|
|
text: user.phoneNumber!,
|
|
),
|
|
if (user.email != null && user.email!.isNotEmpty)
|
|
_buildInfoItem(
|
|
context: context,
|
|
icon: Icons.email,
|
|
text: user.email!,
|
|
),
|
|
],
|
|
),
|
|
if (user.description != null && user.description!.isNotEmpty)
|
|
const SizedBox(height: 8),
|
|
if (user.description != null && user.description!.isNotEmpty)
|
|
Text(user.description!),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|