72 lines
2.2 KiB
Dart
72 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_boring_avatars/flutter_boring_avatars.dart';
|
|
import 'package:huacu_mobile/game_pallete.dart';
|
|
import 'package:huacu_mobile/models/auth_data.dart';
|
|
import 'package:huacu_mobile/models/user_data.dart';
|
|
import 'package:styled_widget/styled_widget.dart';
|
|
|
|
class UserCard extends StatelessWidget {
|
|
final AuthData authData;
|
|
final UserData userData;
|
|
|
|
const UserCard({Key? key, required this.authData, required this.userData})
|
|
: super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return [_buildUserRow(), _buildUserStats()]
|
|
.toColumn(mainAxisAlignment: MainAxisAlignment.spaceAround)
|
|
.padding(horizontal: 20)
|
|
.decorated(
|
|
color: Colors.blueAccent.shade400,
|
|
borderRadius: BorderRadius.circular(20))
|
|
.elevation(
|
|
5,
|
|
shadowColor: Colors.blueAccent.shade400,
|
|
borderRadius: BorderRadius.circular(20),
|
|
)
|
|
.height(175)
|
|
.alignment(Alignment.topCenter);
|
|
}
|
|
|
|
Widget _buildUserRow() {
|
|
return [
|
|
BoringAvatars(
|
|
name: authData.id,
|
|
colors: avatarColors,
|
|
type: BoringAvatarsType.beam,
|
|
).constrained(height: 50, width: 50).padding(right: 10),
|
|
[
|
|
Text(
|
|
authData.login,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
).padding(bottom: 5),
|
|
Text(
|
|
"Our one of the best player",
|
|
style: TextStyle(
|
|
color: Colors.white.withOpacity(0.6),
|
|
fontSize: 12,
|
|
),
|
|
),
|
|
].toColumn(crossAxisAlignment: CrossAxisAlignment.start),
|
|
].toRow();
|
|
}
|
|
|
|
Widget _buildUserStatsItem(String value, String text) => <Widget>[
|
|
Text(value).fontSize(20).textColor(Colors.white).padding(bottom: 5),
|
|
Text(text).textColor(Colors.white.withOpacity(0.6)).fontSize(12),
|
|
].toColumn();
|
|
|
|
Widget _buildUserStats() {
|
|
return [
|
|
_buildUserStatsItem(userData.gamesWon.toString(), 'Wins'),
|
|
_buildUserStatsItem(userData.gamesLost.toString(), 'Losses'),
|
|
]
|
|
.toRow(mainAxisAlignment: MainAxisAlignment.spaceAround)
|
|
.padding(vertical: 10);
|
|
}
|
|
}
|