mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-08-05 04:36:41 +00:00
added saveLogbookPhotos
option
This commit is contained in:
parent
416c3b7d9c
commit
812d3b281a
8 changed files with 66 additions and 11 deletions
|
@ -12,7 +12,7 @@ dependencies:
|
||||||
m3_lightmeter_resources:
|
m3_lightmeter_resources:
|
||||||
git:
|
git:
|
||||||
url: "https://github.com/vodemn/m3_lightmeter_resources"
|
url: "https://github.com/vodemn/m3_lightmeter_resources"
|
||||||
ref: v2.1.0
|
ref: v2.2.0
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
@ -20,5 +20,10 @@ dev_dependencies:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^2.0.0
|
flutter_lints: ^2.0.0
|
||||||
|
|
||||||
|
|
||||||
|
dependency_overrides:
|
||||||
|
m3_lightmeter_resources:
|
||||||
|
path: /Users/vodemn/Documents/GitHub/Vodemn/m3_lightmeter_resources
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"cancel": "Abbrechen",
|
"cancel": "Abbrechen",
|
||||||
"select": "Auswählen",
|
"select": "Auswählen",
|
||||||
"save": "Speichern",
|
"save": "Speichern",
|
||||||
|
"saveNewPhotos": "Neue Fotos speichern",
|
||||||
"settings": "Einstellungen",
|
"settings": "Einstellungen",
|
||||||
"metering": "Messung",
|
"metering": "Messung",
|
||||||
"fractionalStops": "Zwischenstufen",
|
"fractionalStops": "Zwischenstufen",
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"select": "Select",
|
"select": "Select",
|
||||||
"save": "Save",
|
"save": "Save",
|
||||||
|
"saveNewPhotos": "Save new photos",
|
||||||
"settings": "Settings",
|
"settings": "Settings",
|
||||||
"metering": "Metering",
|
"metering": "Metering",
|
||||||
"fractionalStops": "Fractional stops",
|
"fractionalStops": "Fractional stops",
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"cancel": "Annuler",
|
"cancel": "Annuler",
|
||||||
"select": "Sélectionner",
|
"select": "Sélectionner",
|
||||||
"save": "Enregistrer",
|
"save": "Enregistrer",
|
||||||
|
"saveNewPhotos": "Enregistrer les nouvelles photos",
|
||||||
"settings": "Paramètres",
|
"settings": "Paramètres",
|
||||||
"metering": "Mesure",
|
"metering": "Mesure",
|
||||||
"fractionalStops": "Arrêts fractionnaires",
|
"fractionalStops": "Arrêts fractionnaires",
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"cancel": "Отменить",
|
"cancel": "Отменить",
|
||||||
"select": "Выбрать",
|
"select": "Выбрать",
|
||||||
"save": "Сохранить",
|
"save": "Сохранить",
|
||||||
|
"saveNewPhotos": "Сохранять новые фото",
|
||||||
"settings": "Настройки",
|
"settings": "Настройки",
|
||||||
"metering": "Измерения",
|
"metering": "Измерения",
|
||||||
"fractionalStops": "Дробные значения",
|
"fractionalStops": "Дробные значения",
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"cancel": "取消",
|
"cancel": "取消",
|
||||||
"select": "选择",
|
"select": "选择",
|
||||||
"save": "保存",
|
"save": "保存",
|
||||||
|
"saveNewPhotos": "保存新照片",
|
||||||
"settings": "设置",
|
"settings": "设置",
|
||||||
"metering": "测量",
|
"metering": "测量",
|
||||||
"fractionalStops": "EV 步进值",
|
"fractionalStops": "EV 步进值",
|
||||||
|
|
|
@ -30,6 +30,7 @@ class LogbookPhotosProvider extends StatefulWidget {
|
||||||
|
|
||||||
class LogbookPhotosProviderState extends State<LogbookPhotosProvider> {
|
class LogbookPhotosProviderState extends State<LogbookPhotosProvider> {
|
||||||
final Map<String, LogbookPhoto> _photos = {};
|
final Map<String, LogbookPhoto> _photos = {};
|
||||||
|
bool _isEnabled = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -41,10 +42,17 @@ class LogbookPhotosProviderState extends State<LogbookPhotosProvider> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LogbookPhotos(
|
return LogbookPhotos(
|
||||||
photos: context.isPro ? _photos.values.toList(growable: false) : [],
|
photos: context.isPro ? _photos.values.toList(growable: false) : [],
|
||||||
|
isEnabled: _isEnabled,
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void saveLogbookPhotos(bool save) {
|
||||||
|
setState(() {
|
||||||
|
_isEnabled = save;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _init() async {
|
Future<void> _init() async {
|
||||||
_photos.addAll(
|
_photos.addAll(
|
||||||
Map.fromIterable(
|
Map.fromIterable(
|
||||||
|
@ -62,8 +70,7 @@ class LogbookPhotosProviderState extends State<LogbookPhotosProvider> {
|
||||||
required int iso,
|
required int iso,
|
||||||
required int nd,
|
required int nd,
|
||||||
}) async {
|
}) async {
|
||||||
if (context.isPro) {
|
if (context.isPro && _isEnabled) {
|
||||||
// Get coordinates from geolocation service
|
|
||||||
final geolocationService = ServicesProvider.of(context).geolocationService;
|
final geolocationService = ServicesProvider.of(context).geolocationService;
|
||||||
final coordinates = await geolocationService.getCurrentPosition();
|
final coordinates = await geolocationService.getCurrentPosition();
|
||||||
|
|
||||||
|
@ -76,7 +83,7 @@ class LogbookPhotosProviderState extends State<LogbookPhotosProvider> {
|
||||||
nd: nd,
|
nd: nd,
|
||||||
coordinates: coordinates,
|
coordinates: coordinates,
|
||||||
);
|
);
|
||||||
await widget.storageService.addPhoto(photo);
|
//await widget.storageService.addPhoto(photo);
|
||||||
_photos[photo.id] = photo;
|
_photos[photo.id] = photo;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
} else {
|
} else {
|
||||||
|
@ -106,21 +113,45 @@ class LogbookPhotosProviderState extends State<LogbookPhotosProvider> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LogbookPhotos extends InheritedWidget {
|
enum _LogbookPhotosModelAspect { photosList, isEnabled }
|
||||||
|
|
||||||
|
class LogbookPhotos extends InheritedModel<_LogbookPhotosModelAspect> {
|
||||||
final List<LogbookPhoto> photos;
|
final List<LogbookPhoto> photos;
|
||||||
|
final bool isEnabled;
|
||||||
|
|
||||||
const LogbookPhotos({
|
const LogbookPhotos({
|
||||||
required this.photos,
|
required this.photos,
|
||||||
|
required this.isEnabled,
|
||||||
required super.child,
|
required super.child,
|
||||||
});
|
});
|
||||||
|
|
||||||
static List<LogbookPhoto> of(BuildContext context, {bool listen = false}) {
|
static List<LogbookPhoto> of(BuildContext context, {bool listen = true}) {
|
||||||
return (listen
|
return (listen
|
||||||
? context.dependOnInheritedWidgetOfExactType<LogbookPhotos>()
|
? InheritedModel.inheritFrom<LogbookPhotos>(context, aspect: _LogbookPhotosModelAspect.photosList)
|
||||||
: context.getInheritedWidgetOfExactType<LogbookPhotos>())!
|
: context.getInheritedWidgetOfExactType<LogbookPhotos>())!
|
||||||
.photos;
|
.photos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
static bool isEnabledOf(BuildContext context, {bool listen = true}) {
|
||||||
bool updateShouldNotify(LogbookPhotos oldWidget) => !const DeepCollectionEquality().equals(oldWidget.photos, photos);
|
return (listen
|
||||||
|
? InheritedModel.inheritFrom<LogbookPhotos>(context, aspect: _LogbookPhotosModelAspect.isEnabled)
|
||||||
|
: context.getInheritedWidgetOfExactType<LogbookPhotos>())!
|
||||||
|
.isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool updateShouldNotify(LogbookPhotos oldWidget) =>
|
||||||
|
!const DeepCollectionEquality().equals(oldWidget.photos, photos) || oldWidget.isEnabled != isEnabled;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool updateShouldNotifyDependent(LogbookPhotos oldWidget, Set<_LogbookPhotosModelAspect> aspects) {
|
||||||
|
if (aspects.contains(_LogbookPhotosModelAspect.photosList) &&
|
||||||
|
!const DeepCollectionEquality().equals(oldWidget.photos, photos)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (aspects.contains(_LogbookPhotosModelAspect.isEnabled) && oldWidget.isEnabled != isEnabled) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ import 'package:lightmeter/platform_config.dart';
|
||||||
import 'package:lightmeter/providers/logbook_photos_provider.dart';
|
import 'package:lightmeter/providers/logbook_photos_provider.dart';
|
||||||
import 'package:lightmeter/res/dimens.dart';
|
import 'package:lightmeter/res/dimens.dart';
|
||||||
import 'package:lightmeter/screens/logbook/components/grid_tile/widget_grid_tile_logbook_photo.dart';
|
import 'package:lightmeter/screens/logbook/components/grid_tile/widget_grid_tile_logbook_photo.dart';
|
||||||
import 'package:lightmeter/screens/shared/sliver_screen/screen_sliver.dart';
|
|
||||||
import 'package:lightmeter/screens/shared/icon_placeholder/widget_icon_placeholder.dart';
|
import 'package:lightmeter/screens/shared/icon_placeholder/widget_icon_placeholder.dart';
|
||||||
|
import 'package:lightmeter/screens/shared/sliver_screen/screen_sliver.dart';
|
||||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
class LogbookScreen extends StatefulWidget {
|
class LogbookScreen extends StatefulWidget {
|
||||||
|
@ -22,8 +22,22 @@ class _LogbookScreenState extends State<LogbookScreen> with SingleTickerProvider
|
||||||
return SliverScreen(
|
return SliverScreen(
|
||||||
title: Text(S.of(context).logbook),
|
title: Text(S.of(context).logbook),
|
||||||
slivers: [
|
slivers: [
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: Card(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: Dimens.paddingM),
|
||||||
|
child: SwitchListTile(
|
||||||
|
secondary: const Icon(Icons.book_outlined),
|
||||||
|
title: Text(S.of(context).saveNewPhotos),
|
||||||
|
value: LogbookPhotos.isEnabledOf(context),
|
||||||
|
onChanged: LogbookPhotosProvider.of(context).saveLogbookPhotos,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
_PicturesGridBuilder(
|
_PicturesGridBuilder(
|
||||||
values: LogbookPhotos.of(context, listen: true),
|
values: LogbookPhotos.of(context),
|
||||||
onEdit: _editProfile,
|
onEdit: _editProfile,
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
|
@ -66,7 +80,7 @@ class _PicturesGridBuilder extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return SliverPadding(
|
return SliverPadding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),
|
padding: const EdgeInsets.all(Dimens.paddingM),
|
||||||
sliver: SliverGrid(
|
sliver: SliverGrid(
|
||||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
maxCrossAxisExtent:
|
maxCrossAxisExtent:
|
||||||
|
|
Loading…
Reference in a new issue