|
|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
import 'dart:ui' as ui;
|
|
|
|
|
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
@ -10,10 +12,14 @@ import 'package:syncfusion_flutter_core/theme.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:multimedia/data/tvshows.dart';
|
|
|
|
|
|
|
|
|
|
Color _kColorNone = Colors.black;
|
|
|
|
|
Color _kColorInit = const Color.fromARGB(255, 192, 192, 192);
|
|
|
|
|
Color _kColorProg = const Color.fromARGB(255, 0, 0, 192);
|
|
|
|
|
Color _kColorDone = const Color.fromARGB(255, 0, 192, 0);
|
|
|
|
|
|
|
|
|
|
double _kStateWidth = 6;
|
|
|
|
|
double _kStateHeight = 30;
|
|
|
|
|
|
|
|
|
|
class TVShowsScreen extends StatefulWidget {
|
|
|
|
|
const TVShowsScreen({
|
|
|
|
|
super.key,
|
|
|
|
|
@ -179,7 +185,8 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
|
|
|
|
|
navigationMode: GridNavigationMode.row,
|
|
|
|
|
columns: _columns,
|
|
|
|
|
controller: _dataGridController,
|
|
|
|
|
columnWidthMode: ColumnWidthMode.fill,
|
|
|
|
|
columnWidthMode: ColumnWidthMode.auto,
|
|
|
|
|
columnWidthCalculationRange: ColumnWidthCalculationRange.allRows,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: const Center(
|
|
|
|
|
@ -200,16 +207,48 @@ class TVShowDataSource extends DataGridSource {
|
|
|
|
|
buildDataGridRow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String convertState(String state) {
|
|
|
|
|
List<String> stateList = state.split(',');
|
|
|
|
|
int maxEpisode = 0;
|
|
|
|
|
Map stateListMap = {};
|
|
|
|
|
|
|
|
|
|
for (var x = 0; x < stateList.length; x++) {
|
|
|
|
|
List<String> tmp = stateList[x].split('|');
|
|
|
|
|
stateListMap[tmp[0]] = tmp[1];
|
|
|
|
|
|
|
|
|
|
int episode = int.parse(tmp[0]);
|
|
|
|
|
if (episode > maxEpisode) {
|
|
|
|
|
maxEpisode = episode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String stateString = "";
|
|
|
|
|
|
|
|
|
|
for (int x = 0; x < maxEpisode; x++) {
|
|
|
|
|
String s = '0';
|
|
|
|
|
int key = x + 1;
|
|
|
|
|
|
|
|
|
|
if (stateListMap.containsKey('$key')) {
|
|
|
|
|
s = stateListMap['$key'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stateString = stateString + s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return stateString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<DataGridCell> setSeasonData(int maxSeason, List<Season> seasonList) {
|
|
|
|
|
List<DataGridCell> dataGridCell = [];
|
|
|
|
|
int length = seasonList.length;
|
|
|
|
|
|
|
|
|
|
for (int x = 1; x <= maxSeason; x++) {
|
|
|
|
|
String status = '';
|
|
|
|
|
|
|
|
|
|
if (seasonList.length <= x) {
|
|
|
|
|
status = seasonList[x].state;
|
|
|
|
|
if (x <= length) {
|
|
|
|
|
status = convertState(seasonList[x - 1].state);
|
|
|
|
|
}
|
|
|
|
|
dataGridCell.add(DataGridCell(columnName: 'season$x', value: 'status'));
|
|
|
|
|
dataGridCell.add(DataGridCell(columnName: 'season$x', value: status));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dataGridCell;
|
|
|
|
|
@ -244,6 +283,52 @@ class TVShowDataSource extends DataGridSource {
|
|
|
|
|
@override
|
|
|
|
|
List<DataGridRow> get rows => _tvshowDataGridRows;
|
|
|
|
|
|
|
|
|
|
void _drawEpisodeState(Canvas c, Paint p, double x, Color color) {
|
|
|
|
|
Offset p1 = Offset(x + _kStateWidth, 1);
|
|
|
|
|
Offset p2 = Offset(x + _kStateWidth, _kStateHeight - 1);
|
|
|
|
|
Rect rect = Rect.fromLTRB(x, 0, x + _kStateWidth, _kStateHeight);
|
|
|
|
|
p.style = PaintingStyle.fill;
|
|
|
|
|
p.color = color;
|
|
|
|
|
c.drawRect(rect, p);
|
|
|
|
|
p.color = Colors.black;
|
|
|
|
|
c.drawLine(p1, p2, p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Row generateSeasonState(String state) {
|
|
|
|
|
if (state.length == 0) {
|
|
|
|
|
return const Row(
|
|
|
|
|
children: [Text('')],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Color> stateColor = [];
|
|
|
|
|
|
|
|
|
|
for (int x = 0; x < state.length; x++) {
|
|
|
|
|
Color c = _kColorNone;
|
|
|
|
|
|
|
|
|
|
if (state[x] == '1') {
|
|
|
|
|
c = _kColorInit;
|
|
|
|
|
} else if (state[x] == '2') {
|
|
|
|
|
c = _kColorProg;
|
|
|
|
|
} else if (state[x] == '3') {
|
|
|
|
|
c = _kColorDone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stateColor.add(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Row(children: <Widget>[
|
|
|
|
|
...stateColor.map((col) => Text(
|
|
|
|
|
'1',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontFamily: 'geometric',
|
|
|
|
|
fontSize: 30,
|
|
|
|
|
color: col,
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
DataGridRowAdapter buildRow(DataGridRow row) {
|
|
|
|
|
return DataGridRowAdapter(
|
|
|
|
|
@ -277,10 +362,12 @@ class TVShowDataSource extends DataGridSource {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.columnName.startsWith('season')) {
|
|
|
|
|
Row row = generateSeasonState(e.value.toString());
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
|
|
|
|
child: Icon(Icons.location_on),
|
|
|
|
|
child: row,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|