~cytrogen/fluent-reader-mobile

ref: 0e14fd58517e232bdbf350eb0b4f8b18b6c22153 fluent-reader-mobile/lib/components/badge.dart -rw-r--r-- 788 bytes
0e14fd58 — Haoyuan Liu Update README.md 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import 'package:flutter/cupertino.dart';

class Badge extends StatelessWidget {
  Badge(int count, {this.color : CupertinoColors.systemRed, Key key}) :
    label = count >= 1000 ? "999+" : count.toString(),
    super(key: key);

  final String label;
  final CupertinoDynamicColor color;
  final labelStyle = TextStyle(
    color: CupertinoColors.white,
    fontSize: 12
  );

  Widget build(BuildContext context) => Padding(
    padding: EdgeInsets.all(3),
    child: ClipRRect(
      borderRadius: BorderRadius.circular(8),
      child: Container(
        height: 16,
        color: color.resolveFrom(context),
        child: Padding(
          padding: EdgeInsets.symmetric(horizontal: 6, vertical: 1),
          child: Text(label, style: labelStyle,),
        ),
      ),
    )
  );
}