diff --git a/lib/widgets/movies/details/details_screen.dart b/lib/widgets/movies/details/details_screen.dart index 588f1d5..c6300e9 100644 --- a/lib/widgets/movies/details/details_screen.dart +++ b/lib/widgets/movies/details/details_screen.dart @@ -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 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 moviesTmp = await list.map((json) => Movie.fromJson(json)).toList(); diff --git a/lib/widgets/movies/list_screen.dart b/lib/widgets/movies/list_screen.dart index 85f6817..609d823 100644 --- a/lib/widgets/movies/list_screen.dart +++ b/lib/widgets/movies/list_screen.dart @@ -263,48 +263,79 @@ class _MoviesScreenState extends State { @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( 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 { ), ); } + + void addMovie() { + logger.i('add movie'); + } + + void searchMovie() { + logger.i('search movie'); + } + + void updateMovies() { + logger.i('update movies'); + } } class MovieDataSource extends DataGridSource { diff --git a/lib/widgets/tabs_screen.dart b/lib/widgets/tabs_screen.dart index a9569b8..c53812d 100644 --- a/lib/widgets/tabs_screen.dart +++ b/lib/widgets/tabs_screen.dart @@ -29,17 +29,12 @@ class _TabsScreenState extends State { @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, diff --git a/lib/widgets/tvshows/list_screen.dart b/lib/widgets/tvshows/list_screen.dart index 63f4d59..72ac693 100644 --- a/lib/widgets/tvshows/list_screen.dart +++ b/lib/widgets/tvshows/list_screen.dart @@ -249,8 +249,7 @@ class _TVShowsScreenState extends State { Future showTVShowDetails(int index) async { DataGridRow row = tvshowDataSource.effectiveRows.elementAt(index); - List> cells = - row.getCells(); + List> cells = row.getCells(); String seriesID = cells[TVShowColumn.seriesID].value.toString(); bool found = false; @@ -306,7 +305,7 @@ class _TVShowsScreenState extends State { rowColumnIndex: RowColumnIndex(realIndex, i)); } } else {} - filter(); + filter(); } } @@ -361,48 +360,79 @@ class _TVShowsScreenState extends State { @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( 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 { ), ); } + + 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 {