| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- import 'package:intl/intl.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:gradient_text/gradient_text.dart';
- import 'package:wanna_battle/net/HttpManager.dart';
- import 'package:wanna_battle/styles/colors.dart';
- import '../pages/CompetitionRank.dart';
- import '../model/CompetitionInfo.dart';
- import '../pages/CompetitionRooms.dart';
- class Competition extends StatelessWidget {
- final CompetitionInfo competitionInfo;
- const Competition(this.competitionInfo, {Key key}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- child: Container(
- margin: EdgeInsets.only(left: 15, right: 15, bottom: 15),
- child: AspectRatio(
- aspectRatio: 345 / 186,
- child: Stack(
- children: <Widget>[
- AspectRatio(
- aspectRatio: 345 / 186,
- child: CachedNetworkImage(
- imageUrl: competitionInfo.pic,
- fit: BoxFit.cover,
- ),
- ),
- AspectRatio(
- aspectRatio: 345 / 136,
- child: Container(
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [Color(0xff000000).withAlpha(128), Color(0xff000000).withAlpha(0)],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- )),
- ),
- ),
- Align(
- alignment: Alignment.topLeft,
- child: Container(
- margin: EdgeInsets.only(top: 13, left: 15),
- child: Row(
- children: <Widget>[
- Text(
- competitionInfo.competitionName,
- style: TextStyle(
- color: Colors.white,
- fontSize: 18,
- fontWeight: FontWeight.bold,
- ),
- ),
- Container(
- height: 20,
- margin: EdgeInsets.only(left: 6),
- decoration: BoxDecoration(borderRadius: BorderRadius.circular(2), color: Colors.white),
- padding: EdgeInsets.only(left: 4, right: 4),
- child: GestureDetector(
- child: Center(
- child: Text(
- competitionInfo.participatingInfo?.rank != null ? ('第' + competitionInfo.participatingInfo.rank.toString() + '名') : '未上榜',
- style: TextStyle(
- color: Color(0xff19213B),
- fontSize: 12,
- ),
- ),
- ),
- onTap: () {
- Navigator.push(context, CupertinoPageRoute(builder: (context) => CompetitionRank(competitionId: competitionInfo.id)));
- },
- ),
- )
- ],
- ),
- ),
- ),
- Align(
- alignment: Alignment.topLeft,
- child: Container(
- margin: EdgeInsets.only(top: 44, left: 15),
- child: Text(
- readTimestamp(competitionInfo.startTime, 'yyyy.MM.dd') + '-' + readTimestamp(competitionInfo.endTime, 'yyyy.MM.dd'),
- style: TextStyle(
- color: Colors.white,
- fontSize: 12,
- ),
- ),
- ),
- ),
- Align(
- alignment: Alignment.topLeft,
- child: Container(
- decoration: BoxDecoration(border: Border.all(width: 1, color: Colors.white)),
- padding: EdgeInsets.only(left: 2, right: 2),
- margin: EdgeInsets.only(top: 82, left: 15),
- child: Text(
- '赛事奖励',
- style: TextStyle(
- color: Colors.white,
- fontSize: 12,
- ),
- ),
- ),
- ),
- Align(
- alignment: Alignment.bottomLeft,
- child: Container(
- margin: EdgeInsets.only(left: 15, bottom: 12),
- child: Row(
- children: competitionInfo.awardPic.split(',').map<Widget>((f) {
- return Container(
- width: 60,
- height: 60,
- margin: EdgeInsets.only(right: 5),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(2),
- color: Colors.white,
- ),
- child: CachedNetworkImage(
- imageUrl: f,
- fit: BoxFit.contain,
- ),
- );
- }).toList(),
- ),
- ),
- ),
- Align(
- alignment: Alignment.bottomRight,
- child: Container(
- margin: EdgeInsets.only(bottom: 12),
- child: Image.asset(competitionInfo.type == 2 ? 'images/icon_kaishi_vip.png' : 'images/icon_kaishi_putong.png'),
- ),
- )
- ],
- ),
- ),
- ),
- onTap: () {
- Navigator.push(context, CupertinoPageRoute(builder: (context) => CompetitionRooms(competitionInfo)));
- },
- );
- }
- }
- class CompetitionOld extends StatelessWidget {
- final CompetitionInfo competitionInfo;
- CompetitionOld(this.competitionInfo);
- @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)));
- },
- );
- }
- }
|