| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import '../model/CompetitionInfo.dart';
- import 'package:intl/intl.dart';
- import '../pages/RoomList.dart';
- import '../pages/CompetitionRooms.dart';
- import 'package:gradient_text/gradient_text.dart';
- class Competition extends StatelessWidget {
- final CompetitionInfo competitionInfo;
- Competition(this.competitionInfo);
- final Shader linearGradient = LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: <Color>[Color(0xFFFFC84B), Color(0xFFA26A23)],
- ).createShader(Rect.fromLTWH(0.0, 0.0, 200, 70));
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- child: Container(
- color: Color(0xFF293354),
- height: 80,
- margin: EdgeInsets.fromLTRB(15, 7, 15, 7),
- child: Stack(
- overflow: Overflow.visible,
- children: <Widget>[
- Center(
- child: Row(
- children: <Widget>[
- Container(
- margin: EdgeInsets.only(left: 8),
- child: Image.asset(
- 'images/game.png',
- width: 64,
- height: 64,
- ),
- ),
- Expanded(
- child: Container(
- margin: EdgeInsets.only(left: 10),
- height: 64,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- competitionInfo.competitionName,
- style: TextStyle(fontSize: 14, color: Colors.white),
- ),
- Expanded(
- child: GradientText(
- '¥' + competitionInfo.bonus.toString().replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]},'),
- gradient: LinearGradient(
- colors: [Color(0xFFFFC84B), Color(0xFFA26A23)],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- ),
- style: TextStyle(fontSize: 20),
- textAlign: TextAlign.center),
- ),
- Text(
- '比赛时间' +
- DateFormat('yyyy.MM.dd').format(DateTime.fromMicrosecondsSinceEpoch(competitionInfo.startTime * 1000)) +
- '-' +
- DateFormat('yyyy.MM.dd').format(DateTime.fromMicrosecondsSinceEpoch(competitionInfo.endTime * 1000)),
- style: TextStyle(
- color: Color(0xFF9A9CA2),
- fontSize: 11,
- ),
- )
- ],
- ),
- ),
- )
- ],
- ),
- ),
- Positioned(
- right: 0,
- top: 0,
- bottom: 0,
- child: Image.asset('images/icon_jinru.png'),
- ),
- Positioned(
- right: 0,
- top: 0,
- bottom: 0,
- child: Container(
- width: 50,
- height: 80,
- child: Center(
- child: Text(
- '进入',
- style: TextStyle(fontSize: 15, color: Colors.white),
- ),
- ),
- ),
- ),
- Positioned(
- right: 60,
- top: -2,
- width: 52,
- height: 35,
- child: Container(
- transform: Matrix4.translationValues(0.0, -2.0, 0.0),
- child: Builder(
- builder: (context) {
- var src = 'images/icon_paimingno.png';
- if (competitionInfo.participatingInfo != null && competitionInfo.participatingInfo.rank > 0) {
- if (competitionInfo.participatingInfo.rank == 1) {
- src = 'images/icon_paiming01.png';
- } else if (competitionInfo.participatingInfo.rank == 2) {
- src = 'images/icon_paiming02.png';
- } else if (competitionInfo.participatingInfo.rank == 3) {
- src = 'images/icon_paiming03.png';
- } else {
- return Stack(
- children: <Widget>[
- Image.asset('images/icon_paiming0000.png'),
- Align(
- alignment: Alignment.topCenter,
- child: Container(
- margin: EdgeInsets.only(top: 10),
- child: Text(
- competitionInfo.participatingInfo.rank.toString(),
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- color: Colors.white,
- ),
- ),
- ),
- ),
- ],
- );
- }
- }
- return Image.asset(src);
- },
- ),
- ),
- ),
- Align(
- alignment: Alignment.topLeft,
- child: Opacity(
- opacity: competitionInfo.type == 2 ? 1.0 : 0,
- child: Image.asset(
- 'images/home_icon_vip.png',
- width: 28,
- height: 24,
- ),
- ),
- )
- ],
- ),
- ),
- onTap: () {
- Navigator.push(context, CupertinoPageRoute(builder: (context) => CompetitionRooms(competitionInfo)));
- },
- );
- }
- }
|