Merge pull request #688 from ente-io/settings_tweak

Tweak Settings Option
This commit is contained in:
Neeraj Gupta 2022-12-07 14:28:59 +05:30 committed by GitHub
commit 617ad869aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 123 additions and 94 deletions

View file

@ -9,6 +9,7 @@ import 'package:photos/core/constants.dart';
import 'package:photos/core/network.dart';
import 'package:photos/services/notification_service.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tuple/tuple.dart';
class UpdateService {
UpdateService._privateConstructor();
@ -121,6 +122,32 @@ class UpdateService {
}
return _packageInfo.packageName.startsWith("io.ente.photos.independent");
}
bool isFdroidFlavor() {
if (Platform.isIOS) {
return false;
}
return _packageInfo.packageName.startsWith("io.ente.photos.fdroid");
}
// getRateDetails returns details about the place
Tuple2<String, String> getRateDetails() {
if (isFdroidFlavor() || isIndependentFlavor()) {
return const Tuple2(
"AlternativeTo",
"https://alternativeto.net/software/ente/about/",
);
}
return Platform.isAndroid
? const Tuple2(
"play store",
"https://play.google.com/store/apps/details?id=io.ente.photos",
)
: const Tuple2(
"app store",
"https://apps.apple.com/in/app/ente-photos/id1542026904",
);
}
}
class LatestVersionInfo {

View file

@ -19,7 +19,6 @@ import 'package:photos/ui/viewer/file/detail_page.dart';
import 'package:photos/ui/viewer/file/thumbnail_widget.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/utils/date_time_util.dart';
import 'package:photos/utils/local_settings.dart';
import 'package:photos/utils/navigation_util.dart';
import 'package:visibility_detector/visibility_detector.dart';
@ -33,6 +32,7 @@ class LazyLoadingGallery extends StatefulWidget {
final String tag;
final String logTag;
final Stream<int> currentIndexStream;
final int photoGirdSize;
LazyLoadingGallery(
this.files,
@ -44,6 +44,7 @@ class LazyLoadingGallery extends StatefulWidget {
this.tag,
this.currentIndexStream, {
this.logTag = "",
this.photoGirdSize = photoGridSizeDefault,
Key key,
}) : super(key: key ?? UniqueKey());
@ -187,12 +188,10 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(12),
child: getDayWidget(
context,
_files[0].creationTime,
),
getDayWidget(
context,
_files[0].creationTime,
widget.photoGirdSize,
),
ValueListenableBuilder(
valueListenable: _showSelectAllButton,
@ -236,7 +235,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
? _getGallery()
: PlaceHolderWidget(
_files.length,
LocalSettings.instance.getPhotoGridSize(),
widget.photoGirdSize,
),
],
);
@ -258,6 +257,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
_files.length > kRecycleLimit,
_toggleSelectAllFromDay,
_areAllFromDaySelected,
widget.photoGirdSize,
),
);
}
@ -285,6 +285,7 @@ class LazyLoadingGridView extends StatefulWidget {
final bool shouldRecycle;
final ValueNotifier toggleSelectAllFromDay;
final ValueNotifier areAllFilesSelected;
final int photoGridSize;
LazyLoadingGridView(
this.tag,
@ -294,7 +295,8 @@ class LazyLoadingGridView extends StatefulWidget {
this.shouldRender,
this.shouldRecycle,
this.toggleSelectAllFromDay,
this.areAllFilesSelected, {
this.areAllFilesSelected,
this.photoGridSize, {
Key key,
}) : super(key: key ?? UniqueKey());
@ -304,7 +306,6 @@ class LazyLoadingGridView extends StatefulWidget {
class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
bool _shouldRender;
int _photoGridSize;
StreamSubscription<ClearSelectionsEvent> _clearSelectionsEvent;
@override
@ -340,7 +341,6 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
@override
Widget build(BuildContext context) {
_photoGridSize = LocalSettings.instance.getPhotoGridSize();
if (widget.shouldRecycle) {
return _getRecyclableView();
} else {
@ -361,7 +361,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
},
child: _shouldRender
? _getGridView()
: PlaceHolderWidget(widget.filesInDay.length, _photoGridSize),
: PlaceHolderWidget(widget.filesInDay.length, widget.photoGridSize),
);
}
@ -376,7 +376,8 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
});
}
},
child: PlaceHolderWidget(widget.filesInDay.length, _photoGridSize),
child:
PlaceHolderWidget(widget.filesInDay.length, widget.photoGridSize),
);
} else {
return _getGridView();
@ -386,8 +387,8 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
Widget _getGridView() {
return GridView.builder(
shrinkWrap: true,
physics:
const NeverScrollableScrollPhysics(), // to disable GridView's scrolling
physics: const NeverScrollableScrollPhysics(),
// to disable GridView's scrolling
itemBuilder: (context, index) {
return _buildFile(context, widget.filesInDay[index]);
},
@ -395,7 +396,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisSpacing: 2,
mainAxisSpacing: 2,
crossAxisCount: _photoGridSize,
crossAxisCount: widget.photoGridSize,
),
padding: const EdgeInsets.all(0),
);
@ -433,8 +434,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
serverLoadDeferDuration: thumbnailServerLoadDeferDuration,
shouldShowLivePhotoOverlay: true,
key: Key(widget.tag + file.tag),
thumbnailSize: LocalSettings.instance.getPhotoGridSize() <
photoGridSizeDefault
thumbnailSize: widget.photoGridSize < photoGridSizeDefault
? thumbnailLargeSize
: thumbnailSmallSize,
),

View file

@ -28,25 +28,10 @@ class AboutSectionWidget extends StatelessWidget {
Widget _getSectionOptions(BuildContext context) {
return Column(
children: [
sectionOptionSpacing,
const AboutMenuItemWidget(
title: "FAQ",
url: "https://ente.io/faq",
),
sectionOptionSpacing,
const AboutMenuItemWidget(
title: "Terms",
url: "https://ente.io/terms",
),
sectionOptionSpacing,
const AboutMenuItemWidget(
title: "Privacy",
url: "https://ente.io/privacy",
),
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
title: "Source code",
title: "We are open source!",
),
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
@ -56,6 +41,16 @@ class AboutSectionWidget extends StatelessWidget {
},
),
sectionOptionSpacing,
const AboutMenuItemWidget(
title: "Privacy",
url: "https://ente.io/privacy",
),
sectionOptionSpacing,
const AboutMenuItemWidget(
title: "Terms",
url: "https://ente.io/terms",
),
sectionOptionSpacing,
UpdateService.instance.isIndependent()
? Column(
children: [

View file

@ -8,6 +8,7 @@ import 'package:photos/models/backup_status.dart';
import 'package:photos/models/duplicate_files.dart';
import 'package:photos/services/deduplication_service.dart';
import 'package:photos/services/sync_service.dart';
import 'package:photos/services/update_service.dart';
import 'package:photos/theme/ente_theme.dart';
import 'package:photos/ui/backup_folder_selection_page.dart';
import 'package:photos/ui/backup_settings_screen.dart';
@ -81,7 +82,7 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
[
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
title: "Free up space",
title: "Free up device space",
),
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
@ -117,7 +118,7 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
title: "Deduplicate files",
title: "Remove duplicates",
),
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
@ -175,16 +176,8 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop('dialog');
// TODO: Replace with https://pub.dev/packages/in_app_review
if (Platform.isAndroid) {
launchUrlString(
"https://play.google.com/store/apps/details?id=io.ente.photos",
);
} else {
launchUrlString(
"https://apps.apple.com/in/app/ente-photos/id1542026904",
);
}
final url = UpdateService.instance.getRateDetails().item2;
launchUrlString(url);
},
),
TextButton(
@ -238,15 +231,8 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
onPressed: () {
Navigator.of(context, rootNavigator: true).pop('dialog');
// TODO: Replace with https://pub.dev/packages/in_app_review
if (Platform.isAndroid) {
launchUrlString(
"https://play.google.com/store/apps/details?id=io.ente.photos",
);
} else {
launchUrlString(
"https://apps.apple.com/in/app/ente-photos/id1542026904",
);
}
final url = UpdateService.instance.getRateDetails().item2;
launchUrlString(url);
},
),
TextButton(

View file

@ -135,7 +135,7 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
children.addAll([
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
title: "Active sessions",
title: "View active sessions",
),
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,

View file

@ -1,7 +1,5 @@
// @dart=2.9
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:photos/services/update_service.dart';
import 'package:photos/theme/ente_theme.dart';
@ -24,28 +22,39 @@ class SocialSectionWidget extends StatelessWidget {
}
Widget _getSectionOptions(BuildContext context) {
final List<Widget> options = [
sectionOptionSpacing,
const SocialsMenuItemWidget("Twitter", "https://twitter.com/enteio"),
sectionOptionSpacing,
const SocialsMenuItemWidget("Discord", "https://ente.io/discord"),
sectionOptionSpacing,
const SocialsMenuItemWidget("Reddit", "https://reddit.com/r/enteio"),
sectionOptionSpacing,
];
final List<Widget> options = [];
final result = UpdateService.instance.getRateDetails();
final String ratePlace = result.item1;
final String rateUrl = result.item2;
if (!UpdateService.instance.isIndependent()) {
options.addAll(
[
SocialsMenuItemWidget(
"Rate us! ✨",
Platform.isAndroid
? "https://play.google.com/store/apps/details?id=io.ente.photos"
: "https://apps.apple.com/in/app/ente-photos/id1542026904",
),
SocialsMenuItemWidget("Rate us on $ratePlace", rateUrl),
sectionOptionSpacing,
],
);
}
options.addAll(
[
sectionOptionSpacing,
const SocialsMenuItemWidget("Blog", "https://ente.io/blog"),
sectionOptionSpacing,
const SocialsMenuItemWidget("Twitter", "https://twitter.com/enteio"),
sectionOptionSpacing,
const SocialsMenuItemWidget("Mastodon", "https://mstdn.social/@ente"),
sectionOptionSpacing,
const SocialsMenuItemWidget(
"Matrix",
"https://matrix.to/#/#ente:matrix.org",
),
sectionOptionSpacing,
const SocialsMenuItemWidget("Discord", "https://ente.io/discord"),
sectionOptionSpacing,
const SocialsMenuItemWidget("Reddit", "https://reddit.com/r/enteio"),
sectionOptionSpacing,
],
);
return Column(children: options);
}
}

View file

@ -10,6 +10,7 @@ import 'package:photos/ui/common/web_page.dart';
import 'package:photos/ui/components/captioned_text_widget.dart';
import 'package:photos/ui/components/expandable_menu_item_widget.dart';
import 'package:photos/ui/components/menu_item_widget.dart';
import 'package:photos/ui/settings/about_section_widget.dart';
import 'package:photos/ui/settings/common_settings.dart';
import 'package:photos/utils/email_util.dart';
@ -33,7 +34,7 @@ class SupportSectionWidget extends StatelessWidget {
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
title: "Email",
title: "Contact support",
),
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
@ -43,9 +44,14 @@ class SupportSectionWidget extends StatelessWidget {
},
),
sectionOptionSpacing,
const AboutMenuItemWidget(
title: "Frequently asked questions",
url: "https://ente.io/faq",
),
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
title: "Roadmap",
title: "Suggest features",
),
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
@ -59,7 +65,7 @@ class SupportSectionWidget extends StatelessWidget {
final url = Configuration.instance.isLoggedIn()
? endpoint + "?token=" + Configuration.instance.getToken()
: roadmapURL;
return WebPage("Roadmap", url);
return WebPage("Suggest features", url);
},
),
);

View file

@ -77,6 +77,8 @@ class SettingsPage extends StatelessWidget {
contents.addAll([
const SecuritySectionWidget(),
sectionSpacing,
const GeneralSectionWidget(),
sectionSpacing,
]);
if (Platform.isAndroid || kDebugMode) {
@ -91,8 +93,6 @@ class SettingsPage extends StatelessWidget {
sectionSpacing,
const SocialSectionWidget(),
sectionSpacing,
const GeneralSectionWidget(),
sectionSpacing,
const AboutSectionWidget(),
]);

View file

@ -19,6 +19,7 @@ import 'package:photos/ui/huge_listview/huge_listview.dart';
import 'package:photos/ui/huge_listview/lazy_loading_gallery.dart';
import 'package:photos/ui/viewer/gallery/empty_state.dart';
import 'package:photos/utils/date_time_util.dart';
import 'package:photos/utils/local_settings.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
typedef GalleryLoader = Future<FileLoadResult> Function(
@ -77,6 +78,7 @@ class _GalleryState extends State<Gallery> {
StreamSubscription<TabDoubleTapEvent> _tabDoubleTapEvent;
final _forceReloadEventSubscriptions = <StreamSubscription<Event>>[];
String _logTag;
int _photoGridSize;
@override
void initState() {
@ -200,6 +202,7 @@ class _GalleryState extends State<Gallery> {
if (!_hasLoadedFiles) {
return const EnteLoadingWidget();
}
_photoGridSize = LocalSettings.instance.getPhotoGridSize();
return _getListView();
}
@ -246,6 +249,7 @@ class _GalleryState extends State<Gallery> {
.where((event) => event.tag == widget.tagPrefix)
.map((event) => event.index),
logTag: _logTag,
photoGirdSize: _photoGridSize,
);
if (widget.header != null && index == 0) {
gallery = Column(children: [widget.header, gallery]);

View file

@ -18,6 +18,7 @@ import 'package:photos/models/magic_metadata.dart';
import 'package:photos/models/selected_files.dart';
import 'package:photos/services/collections_service.dart';
import 'package:photos/services/sync_service.dart';
import 'package:photos/services/update_service.dart';
import 'package:photos/ui/common/dialogs.dart';
import 'package:photos/ui/common/rename_dialog.dart';
import 'package:photos/ui/sharing/share_collection_widget.dart';
@ -213,15 +214,8 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
onPressed: () {
Navigator.of(context, rootNavigator: true).pop('dialog');
// TODO: Replace with https://pub.dev/packages/in_app_review
if (Platform.isAndroid) {
launchUrlString(
"https://play.google.com/store/apps/details?id=io.ente.photos",
);
} else {
launchUrlString(
"https://apps.apple.com/in/app/ente-photos/id1542026904",
);
}
final url = UpdateService.instance.getRateDetails().item2;
launchUrlString(url);
},
),
TextButton(

View file

@ -1,6 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:photos/core/constants.dart';
import 'package:photos/theme/ente_theme.dart';
const Set<int> monthWith31Days = {1, 3, 5, 7, 8, 10, 12};
@ -195,16 +196,23 @@ bool isLeapYear(DateTime dateTime) {
Widget getDayWidget(
BuildContext context,
int timestamp,
int photoGridSize,
) {
final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
return Container(
alignment: Alignment.centerLeft,
child: Text(
getDayTitle(timestamp),
style: (getDayTitle(timestamp) == "Today")
? textTheme.body
: textTheme.body.copyWith(color: colorScheme.textMuted),
final textStyle =
photoGridSize < photoGridSizeMax ? textTheme.body : textTheme.small;
final double paddingValue = photoGridSize < photoGridSizeMax ? 12.0 : 8.0;
return Padding(
padding: EdgeInsets.all(paddingValue),
child: Container(
alignment: Alignment.centerLeft,
child: Text(
getDayTitle(timestamp),
style: (getDayTitle(timestamp) == "Today")
? textStyle
: textStyle.copyWith(color: colorScheme.textMuted),
),
),
);
}