reader_view.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:flutter/material.dart';
  2. import 'package:shuqi/public.dart';
  3. import 'reader_overlayer.dart';
  4. import 'reader_utils.dart';
  5. import 'reader_config.dart';
  6. class ReaderView extends StatelessWidget {
  7. final Article article;
  8. final int page;
  9. final double topSafeHeight;
  10. ReaderView({required this.article, required this.page, required this.topSafeHeight});
  11. @override
  12. Widget build(BuildContext context) {
  13. return Stack(
  14. children: <Widget>[
  15. Positioned(
  16. left: 0,
  17. top: 0,
  18. right: 0,
  19. bottom: 0,
  20. child: Image.asset('assets/img/read_bg.png', fit: BoxFit.cover)),
  21. ReaderOverlayer(article: article, page: page, topSafeHeight: topSafeHeight),
  22. buildContent(article, page),
  23. ],
  24. );
  25. }
  26. buildContent(Article article, int page) {
  27. var content = article.stringAtPageIndex(page);
  28. if (content.startsWith('\n')) {
  29. content = content.substring(1);
  30. }
  31. return Container(
  32. color: Colors.transparent,
  33. margin: EdgeInsets.fromLTRB(15, topSafeHeight + ReaderUtils.topOffset, 10, Screen.bottomSafeHeight + ReaderUtils.bottomOffset),
  34. child: Text.rich(
  35. TextSpan(children: [TextSpan(text: content, style: TextStyle(fontSize: fixedFontSize(ReaderConfig.instance.fontSize)))]),
  36. textAlign: TextAlign.justify,
  37. ),
  38. );
  39. }
  40. }