12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import 'dart:math';
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/material.dart';
- import 'package:sport/bean/achievement_info.dart';
- const LEVEL_BG_COLOR = [Color(0xffFFEDDF), Color(0xffFFEDDF), Color(0xffFFEDDF), Color(0xffFFEDDF), Color(0xffEBF0FB), Color(0xffEBF0FB), Color(0xffEBF0FB), Color(0xffFFEFD4),Color(0xffFFEFD4), Color(0xffFFEFD4), Color(0xffFFEFD4)];
- const LEVEL_TEXT_COLOR = [Color(0xffCB6C39), Color(0xffCB6C39), Color(0xffCB6C39), Color(0xffCB6C39), Color(0xff767FB5), Color(0xff767FB5), Color(0xff767FB5), Color(0xffFF5B1D), Color(0xffFF5B1D), Color(0xffFF5B1D), Color(0xffFF5B1D)];
- class UserLevelWidget extends StatelessWidget {
- final Level? level;
- @override
- Widget build(BuildContext context) {
- if (level == null) return Container();
- int index = min(LEVEL_BG_COLOR.length - 1, max(1, level?.level ?? 0));
- return Container(
- margin: const EdgeInsets.fromLTRB(6.0, 0, 2, 4),
- child: Stack(
- alignment: Alignment.centerLeft,
- children: [
- Container(
- margin: const EdgeInsets.fromLTRB(12.0, 6, 6, 2),
- padding: const EdgeInsets.only(right: 6, bottom: 3.0, top: 2.0, left: 14.0),
- decoration: BoxDecoration(borderRadius: BorderRadius.circular(100), color: LEVEL_BG_COLOR[index]),
- child: Align(
- alignment: Alignment.centerRight,
- child: Text(
- "Lv.${min(level?.level ?? 0, 99)}",
- style: Theme.of(context).textTheme.subtitle1!.copyWith(color: LEVEL_TEXT_COLOR[index], fontSize: 9.0),
- ),
- ),
- ),
- CachedNetworkImage(
- imageUrl: level?.logo ?? "",
- width: 22.0,
- height: 22.0,
- ),
- ],
- ),
- );
- }
- UserLevelWidget({
- this.level,
- });
- }
|