~cytrogen/fluent-reader-mobile

ref: 0b77b4664f92ca4fce2f347c33fc4298f7bf9c26 fluent-reader-mobile/lib/components/favicon.dart -rw-r--r-- 950 bytes
0b77b466 — 刘浩远 add feedbin support 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
30
31
32
33
34
35
36
import 'package:cached_network_image/cached_network_image.dart';
import 'package:fluent_reader_lite/models/source.dart';
import 'package:flutter/cupertino.dart';

class Favicon extends StatelessWidget {
  final RSSSource source;
  final double size;

  const Favicon(this.source, {this.size: 16, Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final _textStyle = TextStyle(
      fontSize: size - 5,
      color: CupertinoColors.systemGrey6,
    );
    
    if (source.iconUrl != null && source.iconUrl.length > 0) {
      return CachedNetworkImage(
        imageUrl: source.iconUrl,
        width: size,
        height: size,
      );
    } else {
      return Container(
        width: size,
        height: size,
        color: CupertinoColors.systemGrey2,
        child: Center(child: Text(
          source.name.length > 0 ? source.name[0] : "?",
          style: _textStyle,
        )),
      );
    }
  }
}