movie and tvshow list
This commit is contained in:
+40
-50
@@ -3,6 +3,42 @@ import 'package:intl/intl.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncfusion_flutter_datagrid/datagrid.dart';
|
||||
|
||||
class EpisodeCount {
|
||||
int season;
|
||||
int cnt;
|
||||
|
||||
EpisodeCount({
|
||||
required this.season,
|
||||
required this.cnt,
|
||||
});
|
||||
|
||||
factory EpisodeCount.fromJson(Map<String, dynamic> json) {
|
||||
return EpisodeCount(
|
||||
season: int.parse(json['seasonNumber']),
|
||||
cnt: int.parse(json['cnt']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Season {
|
||||
int seasonNumber;
|
||||
int seasonID;
|
||||
String state;
|
||||
|
||||
Season({
|
||||
required this.seasonNumber,
|
||||
required this.seasonID,
|
||||
required this.state,
|
||||
});
|
||||
|
||||
factory Season.fromJson(Map<String, dynamic> json) {
|
||||
return Season(
|
||||
seasonNumber: int.parse(json['seasonNumber']),
|
||||
seasonID: int.parse(json['seasonID']),
|
||||
state: json['state']);
|
||||
}
|
||||
}
|
||||
|
||||
class TVShow {
|
||||
int seriesID;
|
||||
String seriesName;
|
||||
@@ -11,6 +47,7 @@ class TVShow {
|
||||
String resolution;
|
||||
int cliffhanger;
|
||||
String status;
|
||||
List<Season> seasonStatus;
|
||||
|
||||
TVShow({
|
||||
required this.seriesID,
|
||||
@@ -20,6 +57,7 @@ class TVShow {
|
||||
required this.resolution,
|
||||
required this.cliffhanger,
|
||||
required this.status,
|
||||
required this.seasonStatus,
|
||||
});
|
||||
|
||||
factory TVShow.fromJson(Map<String, dynamic> json) {
|
||||
@@ -56,56 +94,8 @@ class TVShow {
|
||||
resolution: json['resolution'],
|
||||
status: json['status'],
|
||||
cliffhanger: int.parse(json['cliffhanger']),
|
||||
seasonStatus:
|
||||
json['seasons'].map<Season>((json) => Season.fromJson(json)).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TVShowDataSource extends DataGridSource {
|
||||
/// Creates the employee data source class with required details.
|
||||
TVShowDataSource(this.tvshows) {
|
||||
buildDataGridRow();
|
||||
}
|
||||
|
||||
void buildDataGridRow() {
|
||||
_tvshowDataGridRows = tvshows
|
||||
.map<DataGridRow>((e) => DataGridRow(cells: [
|
||||
DataGridCell<int>(columnName: 'seriesID', value: e.seriesID),
|
||||
DataGridCell<int>(
|
||||
columnName: 'seriesState', value: e.seriesState),
|
||||
DataGridCell<String>(columnName: 'status', value: e.status),
|
||||
DataGridCell<int>(
|
||||
columnName: 'cliffhanger', value: e.cliffhanger),
|
||||
DataGridCell<String>(
|
||||
columnName: 'seriesName', value: e.seriesName),
|
||||
DataGridCell<String>(
|
||||
columnName: 'firstAired',
|
||||
value: DateFormat('yyyy-MM-dd').format(e.firstAired)),
|
||||
DataGridCell<String>(
|
||||
columnName: 'resolution', value: e.resolution),
|
||||
]))
|
||||
.toList();
|
||||
}
|
||||
|
||||
List<TVShow> tvshows = [];
|
||||
|
||||
List<DataGridRow> _tvshowDataGridRows = [];
|
||||
|
||||
@override
|
||||
List<DataGridRow> get rows => _tvshowDataGridRows;
|
||||
|
||||
@override
|
||||
DataGridRowAdapter buildRow(DataGridRow row) {
|
||||
return DataGridRowAdapter(
|
||||
cells: row.getCells().map<Widget>((e) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(e.value.toString()),
|
||||
);
|
||||
}).toList());
|
||||
}
|
||||
|
||||
void updateDataGrid() {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user