-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(html): Parse newcomer report table
- Loading branch information
Showing
6 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import 'package:collection/collection.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:tsdm_client/constants/layout.dart'; | ||
import 'package:tsdm_client/i18n/strings.g.dart'; | ||
|
||
/// Table info in newcomer report table. | ||
/// | ||
/// Each info occupies a row in table. | ||
class NewcomerReportInfo { | ||
/// Constructor. | ||
NewcomerReportInfo({ | ||
required this.title, | ||
required this.data, | ||
}); | ||
|
||
/// Info title. | ||
final String title; | ||
|
||
/// Info data, may be empty string. | ||
final String data; | ||
} | ||
|
||
/// Card for newcomer report table in thread. | ||
/// | ||
/// Only used in newcomer subreddit. | ||
class NewcomerReportCard extends StatelessWidget { | ||
/// Constructor. | ||
const NewcomerReportCard(this.data, {super.key}); | ||
|
||
/// Data in table. | ||
final List<NewcomerReportInfo> data; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Card( | ||
margin: EdgeInsets.zero, | ||
child: Padding( | ||
padding: edgeInsetsL12T12R12B12, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Icon( | ||
Icons.article_outlined, | ||
color: Theme.of(context).colorScheme.primary, | ||
), | ||
sizedBoxW4H4, | ||
Text( | ||
context.t.html.newcomerReportCard.title, | ||
style: Theme.of(context).textTheme.titleLarge?.copyWith( | ||
color: Theme.of(context).colorScheme.primary, | ||
), | ||
), | ||
], | ||
), | ||
sizedBoxW8H8, | ||
SingleChildScrollView( | ||
scrollDirection: Axis.horizontal, | ||
child: Table( | ||
defaultColumnWidth: const IntrinsicColumnWidth(), | ||
columnWidths: const <int, TableColumnWidth>{ | ||
0: FixedColumnWidth(100), | ||
}, | ||
defaultVerticalAlignment: TableCellVerticalAlignment.middle, | ||
children: data | ||
.mapIndexed( | ||
(idx, e) => TableRow( | ||
decoration: BoxDecoration( | ||
color: idx.isOdd | ||
? Theme.of(context) | ||
.colorScheme | ||
.surfaceContainerHigh | ||
: null, | ||
), | ||
children: [ | ||
TableCell( | ||
child: Text( | ||
e.title, | ||
style: Theme.of(context) | ||
.textTheme | ||
.bodyMedium | ||
?.copyWith( | ||
color: | ||
Theme.of(context).colorScheme.secondary, | ||
), | ||
), | ||
), | ||
TableCell( | ||
child: Text( | ||
e.data, | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
), | ||
), | ||
], | ||
), | ||
) | ||
.toList(), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |