add/search/update

This commit is contained in:
2024-11-18 20:28:18 +01:00
parent 47cae0adb5
commit 21b5de3bb6
4 changed files with 174 additions and 88 deletions
+10 -4
View File
@@ -36,6 +36,8 @@ class MovieDetailsScreen extends StatelessWidget {
String? dbHost = prefs.getString('dbHost');
String? dbPath = prefs.getString('dbPath');
Logger logger = getLogger();
Uri url = Uri(
scheme: dbProtocol,
host: dbHost,
@@ -48,14 +50,18 @@ class MovieDetailsScreen extends StatelessWidget {
);
final response = await http.get(url);
//LATER final bool? error;
//LATER String? errorMessage;
final bool? error;
String? errorMessage;
Map<String, dynamic> movies = json.decode(response.body);
//LATER error = movies['error'];
//LATER errorMessage = movies['errmsg'];
error = movies['error'];
errorMessage = movies['errmsg'];
final list = movies['data'];
if (error!) {
logger.e(errorMessage!);
}
List<Movie> moviesTmp =
await list.map<Movie>((json) => Movie.fromJson(json)).toList();
+81 -38
View File
@@ -263,48 +263,79 @@ class _MoviesScreenState extends State<MoviesScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Movies'),
actions: [
MovieFilterBox(setFilter: setFilter),
const VerticalDivider(
width: 10,
thickness: 3,
indent: 0,
endIndent: 0,
color: Colors.grey,
),
IconButton(
icon: const Icon(Icons.add_circle_outline),
tooltip: 'Add Movie',
onPressed: () {
addMovie();
// if (save()) {
// Navigator.pop(context, movieDetails);
// }
},
),
IconButton(
icon: const Icon(Icons.search_outlined),
tooltip: 'Search for movie',
onPressed: () {
searchMovie();
// Navigator.pop(context, null);
},
),
IconButton(
icon: const Icon(Icons.update_outlined),
tooltip: 'Update movie',
onPressed: () {
updateMovies();
//todo
},
),
],
),
body: FutureBuilder<Object>(
future: generateMovieList(),
builder: (context, data) {
return data.hasData
? Column(
children: [
MovieFilterBox(setFilter: setFilter),
Expanded(
child: SfDataGridTheme(
data: const SfDataGridThemeData(
headerColor: Color(0xff009889),
),
child: SfDataGrid(
source: movieDataSource,
selectionMode: SelectionMode.single,
navigationMode: GridNavigationMode.row,
columns: _columns,
controller: _dataGridController,
columnWidthMode: ColumnWidthMode.auto,
columnWidthCalculationRange:
ColumnWidthCalculationRange.allRows,
onCellTap: (DataGridCellTapDetails details) {
int index = details.rowColumnIndex.rowIndex - 1;
if (index < 0) {
return;
}
showMovieDetails(index);
},
onCellDoubleTap:
(DataGridCellDoubleTapDetails details) {
print(details.rowColumnIndex);
},
onCellLongPress:
(DataGridCellLongPressDetails details) {
print(details.rowColumnIndex);
},
onCellSecondaryTap: (DataGridCellTapDetails details) {
print(details.rowColumnIndex);
},
),
)),
],
? SfDataGridTheme(
data: const SfDataGridThemeData(
headerColor: Color(0xff009889),
),
child: SfDataGrid(
source: movieDataSource,
selectionMode: SelectionMode.single,
navigationMode: GridNavigationMode.row,
columns: _columns,
controller: _dataGridController,
columnWidthMode: ColumnWidthMode.auto,
columnWidthCalculationRange:
ColumnWidthCalculationRange.allRows,
onCellTap: (DataGridCellTapDetails details) {
int index = details.rowColumnIndex.rowIndex - 1;
if (index < 0) {
return;
}
showMovieDetails(index);
},
onCellDoubleTap: (DataGridCellDoubleTapDetails details) {
print(details.rowColumnIndex);
},
onCellLongPress: (DataGridCellLongPressDetails details) {
print(details.rowColumnIndex);
},
onCellSecondaryTap: (DataGridCellTapDetails details) {
print(details.rowColumnIndex);
},
),
)
: const Center(
child: CircularProgressIndicator(
@@ -316,6 +347,18 @@ class _MoviesScreenState extends State<MoviesScreen> {
),
);
}
void addMovie() {
logger.i('add movie');
}
void searchMovie() {
logger.i('search movie');
}
void updateMovies() {
logger.i('update movies');
}
}
class MovieDataSource extends DataGridSource {
-5
View File
@@ -29,17 +29,12 @@ class _TabsScreenState extends State<TabsScreen> {
@override
Widget build(BuildContext context) {
Widget activePage = const TVShowsScreen();
var activePageTitle = 'TV Shows';
if (_selectedPageIndex == 1) {
activePage = const MoviesScreen();
activePageTitle = 'Movies';
}
return Scaffold(
appBar: AppBar(
title: Text(activePageTitle),
),
body: activePage,
bottomNavigationBar: BottomNavigationBar(
onTap: _selectPage,
+83 -41
View File
@@ -249,8 +249,7 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
Future<void> showTVShowDetails(int index) async {
DataGridRow row = tvshowDataSource.effectiveRows.elementAt(index);
List<DataGridCell<dynamic>> cells =
row.getCells();
List<DataGridCell<dynamic>> cells = row.getCells();
String seriesID = cells[TVShowColumn.seriesID].value.toString();
bool found = false;
@@ -306,7 +305,7 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
rowColumnIndex: RowColumnIndex(realIndex, i));
}
} else {}
filter();
filter();
}
}
@@ -361,48 +360,79 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('TV Shows'),
actions: [
TVShowFilterBox(setFilter: setFilter),
const VerticalDivider(
width: 10,
thickness: 3,
indent: 0,
endIndent: 0,
color: Colors.grey,
),
IconButton(
icon: const Icon(Icons.add_circle_outline),
tooltip: 'Add TV Show',
onPressed: () {
addTVShow();
// if (save()) {
// Navigator.pop(context, movieDetails);
// }
},
),
IconButton(
icon: const Icon(Icons.search_outlined),
tooltip: 'Search for TV Show',
onPressed: () {
searchTVShow();
// Navigator.pop(context, null);
},
),
IconButton(
icon: const Icon(Icons.update_outlined),
tooltip: 'Update TVShows',
onPressed: () {
updateTVShows();
//todo
},
),
],
),
body: FutureBuilder<Object>(
future: generateTVShowList(),
builder: (context, data) {
return data.hasData
? Column(
children: [
TVShowFilterBox(setFilter: setFilter),
Expanded(
child: SfDataGridTheme(
data: const SfDataGridThemeData(
headerColor: Color(0xff009889),
),
child: SfDataGrid(
source: tvshowDataSource,
selectionMode: SelectionMode.single,
navigationMode: GridNavigationMode.row,
columns: _columns,
controller: _dataGridController,
columnWidthMode: ColumnWidthMode.auto,
columnWidthCalculationRange:
ColumnWidthCalculationRange.allRows,
onCellTap: (DataGridCellTapDetails details) {
int index = details.rowColumnIndex.rowIndex - 1;
if (index < 0) {
return;
}
showTVShowDetails(index);
},
onCellDoubleTap:
(DataGridCellDoubleTapDetails details) {
print(details.rowColumnIndex);
},
onCellLongPress:
(DataGridCellLongPressDetails details) {
print(details.rowColumnIndex);
},
onCellSecondaryTap: (DataGridCellTapDetails details) {
print(details.rowColumnIndex);
},
),
)),
],
? SfDataGridTheme(
data: const SfDataGridThemeData(
headerColor: Color(0xff009889),
),
child: SfDataGrid(
source: tvshowDataSource,
selectionMode: SelectionMode.single,
navigationMode: GridNavigationMode.row,
columns: _columns,
controller: _dataGridController,
columnWidthMode: ColumnWidthMode.auto,
columnWidthCalculationRange:
ColumnWidthCalculationRange.allRows,
onCellTap: (DataGridCellTapDetails details) {
int index = details.rowColumnIndex.rowIndex - 1;
if (index < 0) {
return;
}
showTVShowDetails(index);
},
onCellDoubleTap: (DataGridCellDoubleTapDetails details) {
print(details.rowColumnIndex);
},
onCellLongPress: (DataGridCellLongPressDetails details) {
print(details.rowColumnIndex);
},
onCellSecondaryTap: (DataGridCellTapDetails details) {
print(details.rowColumnIndex);
},
),
)
: const Center(
child: CircularProgressIndicator(
@@ -414,6 +444,18 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
),
);
}
void addTVShow() {
logger.i('add TV Show');
}
void searchTVShow() {
logger.i('search TV Show');
}
void updateTVShows() {
logger.i('update TV Shows');
}
}
class TVShowDataSource extends DataGridSource {