~cytrogen/fluent-reader-mobile

ref: 7629f7f3978360911c67b9e4364e38a815e00322 fluent-reader-mobile/lib/components/badge.dart -rw-r--r-- 788 bytes
7629f7f3 — Haoyuan Liu Merge pull request #77 from Alkarex/patch-1 2 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,),
        ),
      ),
    )
  );
}