Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
deckerst committed Sep 4, 2020
2 parents e4b5566 + bcb32cd commit dc907a0
Show file tree
Hide file tree
Showing 64 changed files with 1,052 additions and 991 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches:
- develop

# TODO TLAD run `flutter format -l 1000 .` and fail if any

jobs:
build:
name: Check code quality.
Expand Down
55 changes: 29 additions & 26 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:aves/model/settings.dart';
import 'package:aves/model/settings/settings.dart';
import 'package:aves/widgets/common/data_providers/settings_provider.dart';
import 'package:aves/widgets/common/icons.dart';
import 'package:aves/widgets/home_page.dart';
import 'package:aves/widgets/welcome_page.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:overlay_support/overlay_support.dart';

void main() {
// HttpClient.enableTimelineLogging = true; // enable network traffic logging
Expand Down Expand Up @@ -41,34 +42,36 @@ class _AvesAppState extends State<AvesApp> {
// place the settings provider above `MaterialApp`
// so it can be used during navigation transitions
return SettingsProvider(
child: MaterialApp(
title: 'Aves',
theme: ThemeData(
brightness: Brightness.dark,
accentColor: accentColor,
scaffoldBackgroundColor: Colors.grey[900],
buttonColor: accentColor,
toggleableActiveColor: accentColor,
tooltipTheme: TooltipThemeData(
verticalOffset: 32,
),
appBarTheme: AppBarTheme(
textTheme: TextTheme(
headline6: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
fontFamily: 'Concourse Caps',
child: OverlaySupport(
child: MaterialApp(
title: 'Aves',
theme: ThemeData(
brightness: Brightness.dark,
accentColor: accentColor,
scaffoldBackgroundColor: Colors.grey[900],
buttonColor: accentColor,
toggleableActiveColor: accentColor,
tooltipTheme: TooltipThemeData(
verticalOffset: 32,
),
appBarTheme: AppBarTheme(
textTheme: TextTheme(
headline6: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
fontFamily: 'Concourse Caps',
),
),
),
),
),
home: FutureBuilder<void>(
future: _appSetup,
builder: (context, snapshot) {
if (snapshot.hasError) return Icon(AIcons.error);
if (snapshot.connectionState != ConnectionState.done) return Scaffold();
return settings.hasAcceptedTerms ? HomePage() : WelcomePage();
},
home: FutureBuilder<void>(
future: _appSetup,
builder: (context, snapshot) {
if (snapshot.hasError) return Icon(AIcons.error);
if (snapshot.connectionState != ConnectionState.done) return Scaffold();
return settings.hasAcceptedTerms ? HomePage() : WelcomePage();
},
),
),
),
);
Expand Down
28 changes: 28 additions & 0 deletions lib/model/settings/coordinate_format.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:aves/utils/geo_utils.dart';
import 'package:tuple/tuple.dart';

enum CoordinateFormat { dms, decimal }

extension ExtraCoordinateFormat on CoordinateFormat {
String get name {
switch (this) {
case CoordinateFormat.dms:
return 'DMS';
case CoordinateFormat.decimal:
return 'Decimal degrees';
default:
return toString();
}
}

String format(Tuple2<double, double> latLng) {
switch (this) {
case CoordinateFormat.dms:
return toDMS(latLng).join(', ');
case CoordinateFormat.decimal:
return [latLng.item1, latLng.item2].map((n) => n.toStringAsFixed(6)).join(', ');
default:
return toString();
}
}
}
28 changes: 28 additions & 0 deletions lib/model/settings/home_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:aves/widgets/album/collection_page.dart';
import 'package:aves/widgets/filter_grids/albums_page.dart';

enum HomePageSetting { collection, albums }

extension ExtraHomePageSetting on HomePageSetting {
String get name {
switch (this) {
case HomePageSetting.collection:
return 'Collection';
case HomePageSetting.albums:
return 'Albums';
default:
return toString();
}
}

String get routeName {
switch (this) {
case HomePageSetting.collection:
return CollectionPage.routeName;
case HomePageSetting.albums:
return AlbumListPage.routeName;
default:
return toString();
}
}
}
106 changes: 48 additions & 58 deletions lib/model/settings.dart → lib/model/settings/settings.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:aves/utils/geo_utils.dart';
import 'package:aves/model/settings/coordinate_format.dart';
import 'package:aves/model/settings/home_page.dart';
import 'package:aves/widgets/fullscreen/info/location_section.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tuple/tuple.dart';

import 'source/enums.dart';
import '../source/enums.dart';

final Settings settings = Settings._private();

Expand All @@ -16,18 +16,27 @@ class Settings extends ChangeNotifier {

Settings._private();

// preferences
// app
static const hasAcceptedTermsKey = 'has_accepted_terms';
static const mustBackTwiceToExitKey = 'must_back_twice_to_exit';
static const homePageKey = 'home_page';
static const catalogTimeZoneKey = 'catalog_time_zone';

// collection
static const collectionGroupFactorKey = 'collection_group_factor';
static const collectionSortFactorKey = 'collection_sort_factor';
static const collectionTileExtentKey = 'collection_tile_extent';
static const hasAcceptedTermsKey = 'has_accepted_terms';

// filter grids
static const albumSortFactorKey = 'album_sort_factor';

// info
static const infoMapStyleKey = 'info_map_style';
static const infoMapZoomKey = 'info_map_zoom';
static const launchPageKey = 'launch_page';
static const coordinateFormatKey = 'coordinates_format';

// rendering
static const svgBackgroundKey = 'svg_background';
static const albumSortFactorKey = 'album_sort_factor';

Future<void> init() async {
_prefs = await SharedPreferences.getInstance();
Expand All @@ -37,10 +46,26 @@ class Settings extends ChangeNotifier {
return _prefs.clear();
}

// app

bool get hasAcceptedTerms => getBoolOrDefault(hasAcceptedTermsKey, false);

set hasAcceptedTerms(bool newValue) => setAndNotify(hasAcceptedTermsKey, newValue);

bool get mustBackTwiceToExit => getBoolOrDefault(mustBackTwiceToExitKey, true);

set mustBackTwiceToExit(bool newValue) => setAndNotify(mustBackTwiceToExitKey, newValue);

HomePageSetting get homePage => getEnumOrDefault(homePageKey, HomePageSetting.collection, HomePageSetting.values);

set homePage(HomePageSetting newValue) => setAndNotify(homePageKey, newValue.toString());

String get catalogTimeZone => _prefs.getString(catalogTimeZoneKey) ?? '';

set catalogTimeZone(String newValue) => setAndNotify(catalogTimeZoneKey, newValue);

// collection

EntryGroupFactor get collectionGroupFactor => getEnumOrDefault(collectionGroupFactorKey, EntryGroupFactor.month, EntryGroupFactor.values);

set collectionGroupFactor(EntryGroupFactor newValue) => setAndNotify(collectionGroupFactorKey, newValue.toString());
Expand All @@ -53,33 +78,39 @@ class Settings extends ChangeNotifier {

set collectionTileExtent(double newValue) => setAndNotify(collectionTileExtentKey, newValue);

EntryMapStyle get infoMapStyle => getEnumOrDefault(infoMapStyleKey, EntryMapStyle.stamenWatercolor, EntryMapStyle.values);
// filter grids

set infoMapStyle(EntryMapStyle newValue) => setAndNotify(infoMapStyleKey, newValue.toString());
ChipSortFactor get albumSortFactor => getEnumOrDefault(albumSortFactorKey, ChipSortFactor.name, ChipSortFactor.values);

double get infoMapZoom => _prefs.getDouble(infoMapZoomKey) ?? 12;
set albumSortFactor(ChipSortFactor newValue) => setAndNotify(albumSortFactorKey, newValue.toString());

set infoMapZoom(double newValue) => setAndNotify(infoMapZoomKey, newValue);
// info

bool get hasAcceptedTerms => getBoolOrDefault(hasAcceptedTermsKey, false);
EntryMapStyle get infoMapStyle => getEnumOrDefault(infoMapStyleKey, EntryMapStyle.stamenWatercolor, EntryMapStyle.values);

set hasAcceptedTerms(bool newValue) => setAndNotify(hasAcceptedTermsKey, newValue);
set infoMapStyle(EntryMapStyle newValue) => setAndNotify(infoMapStyleKey, newValue.toString());

LaunchPage get launchPage => getEnumOrDefault(launchPageKey, LaunchPage.collection, LaunchPage.values);
double get infoMapZoom => _prefs.getDouble(infoMapZoomKey) ?? 12;

set launchPage(LaunchPage newValue) => setAndNotify(launchPageKey, newValue.toString());
set infoMapZoom(double newValue) => setAndNotify(infoMapZoomKey, newValue);

CoordinateFormat get coordinateFormat => getEnumOrDefault(coordinateFormatKey, CoordinateFormat.dms, CoordinateFormat.values);

set coordinateFormat(CoordinateFormat newValue) => setAndNotify(coordinateFormatKey, newValue.toString());

// rendering

int get svgBackground => _prefs.getInt(svgBackgroundKey) ?? 0xFFFFFFFF;

set svgBackground(int newValue) => setAndNotify(svgBackgroundKey, newValue);

ChipSortFactor get albumSortFactor => getEnumOrDefault(albumSortFactorKey, ChipSortFactor.date, ChipSortFactor.values);
// utils

set albumSortFactor(ChipSortFactor newValue) => setAndNotify(albumSortFactorKey, newValue.toString());
// `RoutePredicate`
RoutePredicate navRemoveRoutePredicate(String pushedRouteName) {
final home = homePage.routeName;
return (route) => pushedRouteName != home && route.settings?.name == home;
}

// convenience methods

Expand Down Expand Up @@ -125,44 +156,3 @@ class Settings extends ChangeNotifier {
}
}
}

enum LaunchPage { collection, albums }

extension ExtraLaunchPage on LaunchPage {
String get name {
switch (this) {
case LaunchPage.collection:
return 'All Media';
case LaunchPage.albums:
return 'Albums';
default:
return toString();
}
}
}

enum CoordinateFormat { dms, decimal }

extension ExtraCoordinateFormat on CoordinateFormat {
String get name {
switch (this) {
case CoordinateFormat.dms:
return 'DMS';
case CoordinateFormat.decimal:
return 'Decimal degrees';
default:
return toString();
}
}

String format(Tuple2<double, double> latLng) {
switch (this) {
case CoordinateFormat.dms:
return toDMS(latLng).join(', ');
case CoordinateFormat.decimal:
return [latLng.item1, latLng.item2].map((n) => n.toStringAsFixed(6)).join(', ');
default:
return toString();
}
}
}
2 changes: 1 addition & 1 deletion lib/model/source/collection_lens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'dart:collection';
import 'package:aves/model/filters/album.dart';
import 'package:aves/model/filters/filters.dart';
import 'package:aves/model/image_entry.dart';
import 'package:aves/model/settings.dart';
import 'package:aves/model/settings/settings.dart';
import 'package:aves/model/source/collection_source.dart';
import 'package:aves/model/source/tag.dart';
import 'package:aves/utils/android_file_utils.dart';
Expand Down
7 changes: 0 additions & 7 deletions lib/utils/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ class Constants {
color: Color(0xFFEEEEEE),
fontSize: 20,
fontFamily: 'Concourse Caps',
shadows: [
Shadow(
offset: Offset(0, 2),
blurRadius: 3,
color: Color(0xFF212121),
),
],
);

static const List<Dependency> androidDependencies = [
Expand Down
1 change: 1 addition & 0 deletions lib/utils/durations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ class Durations {
static const collectionScalingCompleteNotificationDelay = Duration(milliseconds: 300);
static const videoProgressTimerInterval = Duration(milliseconds: 300);
static Duration staggeredAnimationDelay = Durations.staggeredAnimation ~/ 6 * timeDilation;
static const doubleBackTimerDelay = Duration(milliseconds: 1000);
}
5 changes: 5 additions & 0 deletions lib/utils/flutter_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:flutter/widgets.dart';

extension ExtraContext on BuildContext {
String get currentRouteName => ModalRoute.of(this)?.settings?.name;
}
2 changes: 2 additions & 0 deletions lib/widgets/about/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:package_info/package_info.dart';

class AboutPage extends StatelessWidget {
static const routeName = '/about';

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
Loading

0 comments on commit dc907a0

Please sign in to comment.