Skip to content

Commit

Permalink
Merge pull request #36 from msthoma/evaluation_4
Browse files Browse the repository at this point in the history
Minor UI improvements and bug fixes
  • Loading branch information
msthoma authored Feb 17, 2021
2 parents 0a604e5 + 05af381 commit 23aeae8
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 53 deletions.
5 changes: 5 additions & 0 deletions assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Version 0.12.2 (2021-02-17)
- Minor UI improvements
- New tile in settings with link to the Gallery's website
- More bug fixes

## Version 0.12.1 (2021-02-15)
- Bug fixes

Expand Down
23 changes: 23 additions & 0 deletions lib/data/artists_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,27 @@ class ArtistsDao extends DatabaseAccessor<AppDatabase> with _$ArtistsDaoMixin {
name: e.readTable(artistTranslations).name,
biography: e.readTable(artistTranslations).biography);
}).watch();

/// Get artist by id.
Future<Artist> getArtistById({
@required String artistId,
String languageCode = "en",
}) {
return ((select(artists)..where((tbl) => tbl.id.equals(artistId))).join(
[
leftOuterJoin(
artistTranslations, artistTranslations.id.equalsExp(artists.id))
],
)..where(artistTranslations.languageCode.equals(languageCode)))
.map(
(e) {
Artist artist = e.readTable(artists);
ArtistTranslation translation = e.readTable(artistTranslations);
return artist.copyWith(
name: translation.name,
biography: translation.biography,
);
},
).getSingle();
}
}
2 changes: 1 addition & 1 deletion lib/lang/localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ part 'localization.g.dart';
///
/// In case the commands above report conflicts, append
/// `--delete-conflicting-outputs` and re-run.
@SheetLocalization(docId, i18nSheetID, 19)
@SheetLocalization(docId, i18nSheetID, 23)
// The number is the generated version, and must be incremented each time the
// GSheet is updated, to regenerate a new version of the labels.
class AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
Expand Down
34 changes: 29 additions & 5 deletions lib/lang/localization.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 47 additions & 6 deletions lib/ui/pages/artwork_details_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_lorem/flutter_lorem.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:modern_art_app/data/artists_dao.dart';
import 'package:modern_art_app/data/database.dart';
import 'package:modern_art_app/ui/pages/artist_details_page.dart';
import 'package:modern_art_app/utils/extensions.dart';
import 'package:modern_art_app/utils/utils.dart';
import 'package:photo_view/photo_view.dart';
import 'package:provider/provider.dart';

class ArtworkDetailsPage extends StatelessWidget {
const ArtworkDetailsPage(
Expand Down Expand Up @@ -70,12 +73,44 @@ class ArtworkDetailsPage extends StatelessWidget {
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(16.0, 0.0, 8.0, 8.0),
child: Text(
"${artwork.artist}" +
(artwork.year.isNotEmpty ? ", ${artwork.year}" : ""),
style: TextStyle(fontSize: 16, fontStyle: FontStyle.italic),
InkWell(
onTap: () {
// navigate to artist's details
Provider.of<ArtistsDao>(context, listen: false)
.getArtistById(
artistId: artwork.artistId,
languageCode: context.locale().languageCode,
)
.then((artist) => Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ArtistDetailsPage(artist: artist)),
));
},
child: Padding(
padding: const EdgeInsets.fromLTRB(16.0, 0.0, 8.0, 8.0),
child: RichText(
text: TextSpan(
children: [
TextSpan(
text: artwork.artist,
style: TextStyle(
fontSize: 16,
fontStyle: FontStyle.italic,
color: Theme.of(context).accentColor,
),
),
TextSpan(
text: " (${artwork.year})",
style: TextStyle(
fontSize: 16,
fontStyle: FontStyle.italic,
),
),
],
),
),
),
),
Padding(
Expand Down Expand Up @@ -125,3 +160,9 @@ class ItemZoomPage extends StatelessWidget {
);
}
}

// Text(
// "${artwork.artist}" +
// (artwork.year.isNotEmpty ? ", ${artwork.year}" : ""),
// style: TextStyle(fontSize: 16, fontStyle: FontStyle.italic),
// )
63 changes: 39 additions & 24 deletions lib/ui/pages/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class _MainPageState extends State<MainPage> {
/// Navigator.of(context) methods.
final _navigatorKey = GlobalKey<NavigatorState>();

GlobalKey<ConvexAppBarState> _appBarKey = GlobalKey<ConvexAppBarState>();

int _currentIndex = 0;

@override
Expand Down Expand Up @@ -55,43 +57,46 @@ class _MainPageState extends State<MainPage> {
// handling of the back button on Android
onWillPop: () async {
if (_navigatorKey.currentState.canPop()) {
print("CAN POP");
_navigatorKey.currentState.pop();
setState(() {
_appBarKey.currentState.animateTo(0);
_currentIndex = 0;
});
return false;
}
return true;
},
child: Navigator(
key: _navigatorKey,
observers: [_heroController],
initialRoute: "/",
initialRoute: Routes.explorePage,
onGenerateRoute: (RouteSettings settings) {
WidgetBuilder builder;
// route names
// todo move route names into a list? map?
// navigator routes
WidgetBuilder bldr;
switch (settings.name) {
case "/":
builder = (BuildContext context) => ExplorePage();
case Routes.explorePage:
bldr = (BuildContext context) => ExplorePage();
break;
case "/identify":
builder =
(BuildContext context) => ModelSelection(widget.cameras);
case Routes.identifyPage:
bldr = (BuildContext context) => ModelSelection(widget.cameras);
break;
case "/settings":
builder = (BuildContext context) => SettingsPage();
case Routes.settingsPage:
bldr = (BuildContext context) => SettingsPage();
break;
default:
throw Exception("Invalid route: ${settings.name}");
}
return MaterialPageRoute(
builder: builder,
settings: settings,
);
return MaterialPageRoute(builder: bldr, settings: settings);
},
),
),
bottomNavigationBar: ConvexAppBar(
key: _appBarKey,
style: TabStyle.fixed,
backgroundColor: ThemeData.dark().primaryColor,
backgroundColor: Colors.grey.shade800,
activeColor: Theme.of(context).accentColor,
elevation: 20,
initialActiveIndex: _currentIndex,
items: [
TabItem(icon: Icons.home_rounded, title: strings.nav.explore),
Expand All @@ -104,19 +109,23 @@ class _MainPageState extends State<MainPage> {
// when the Explore tab is selected, remove everything else from
// the navigator's stack
_navigatorKey.currentState
.pushNamedAndRemoveUntil("/", (_) => false);
.pushNamedAndRemoveUntil(Routes.explorePage, (_) => false);
break;
case 1:
_navigatorKey.currentState.pushNamedAndRemoveUntil(
"/identify", ModalRoute.withName("/"));
Routes.identifyPage,
ModalRoute.withName(Routes.explorePage),
);
break;
case 2:
// prevent multiple pushes of settings page
if (_currentIndex != 2) {
// here also remove everything else apart from "/"
_navigatorKey.currentState.pushNamedAndRemoveUntil(
"/settings", ModalRoute.withName("/"));
}
// prevent multiple pushes of Settings page
// if (_currentIndex != 2) {
// here also remove everything else apart from "/"
_navigatorKey.currentState.pushNamedAndRemoveUntil(
Routes.settingsPage,
ModalRoute.withName(Routes.explorePage),
);
// }
break;
}
setState(() {
Expand All @@ -127,3 +136,9 @@ class _MainPageState extends State<MainPage> {
);
}
}

class Routes {
static const String explorePage = "/";
static const String identifyPage = "/identify";
static const String settingsPage = "/settings";
}
Loading

0 comments on commit 23aeae8

Please sign in to comment.