Direct user to wiki when opening shared album the 1st time

This commit is contained in:
Ming Ming 2021-11-27 01:14:50 +08:00
parent 16553db19d
commit 965e0125a3
6 changed files with 106 additions and 0 deletions

View file

@ -1,4 +1,6 @@
const mainUrl = "https://gitlab.com/nkming2/nc-photos/-/wikis/home";
const peopleUrl = "https://gitlab.com/nkming2/nc-photos/-/wikis/help/people";
const sharedAlbumLimitationsUrl =
"https://gitlab.com/nkming2/nc-photos/-/wikis/help/shared-album#limitations";
const twoFactorAuthUrl =
"https://gitlab.com/nkming2/nc-photos/-/wikis/help/two-factor-authentication";

View file

@ -1079,6 +1079,15 @@
"@addUserInputHint": {
"description": "Input a user name to share this album with"
},
"sharedAlbumInfoDialogTitle": "Introducing shared album",
"@sharedAlbumInfoDialogTitle": {
"description": "This dialog is shown when user first open a shared album"
},
"sharedAlbumInfoDialogContent": "Shared album allows multiple users on the same server to access the same album. Please read carefully the limitations before continuing",
"@sharedAlbumInfoDialogContent": {
"description": "This dialog is shown when user first open a shared album"
},
"learnMoreButtonLabel": "LEARN MORE",
"errorUnauthenticated": "Unauthenticated access. Please sign-in again if the problem continues",
"@errorUnauthenticated": {

View file

@ -50,6 +50,9 @@
"extraShareDescription",
"defaultButtonLabel",
"addUserInputHint",
"sharedAlbumInfoDialogTitle",
"sharedAlbumInfoDialogContent",
"learnMoreButtonLabel",
"errorAlbumDowngrade"
],
@ -118,6 +121,9 @@
"extraShareDescription",
"defaultButtonLabel",
"addUserInputHint",
"sharedAlbumInfoDialogTitle",
"sharedAlbumInfoDialogContent",
"learnMoreButtonLabel",
"errorAlbumDowngrade"
],
@ -241,12 +247,18 @@
"extraShareDescription",
"defaultButtonLabel",
"addUserInputHint",
"sharedAlbumInfoDialogTitle",
"sharedAlbumInfoDialogContent",
"learnMoreButtonLabel",
"errorAlbumDowngrade"
],
"es": [
"settingsMapProviderTitle",
"addUserInputHint",
"sharedAlbumInfoDialogTitle",
"sharedAlbumInfoDialogContent",
"learnMoreButtonLabel",
"errorAlbumDowngrade"
],
@ -350,6 +362,9 @@
"extraShareDescription",
"defaultButtonLabel",
"addUserInputHint",
"sharedAlbumInfoDialogTitle",
"sharedAlbumInfoDialogContent",
"learnMoreButtonLabel",
"errorAlbumDowngrade"
],
@ -426,6 +441,9 @@
"extraShareDescription",
"defaultButtonLabel",
"addUserInputHint",
"sharedAlbumInfoDialogTitle",
"sharedAlbumInfoDialogContent",
"learnMoreButtonLabel",
"errorAlbumDowngrade"
]
}

View file

@ -144,6 +144,12 @@ class Pref {
Future<bool> setLabEnableSharedAlbum(bool value) =>
provider.setBool(PrefKey.labEnableSharedAlbum, value);
bool? hasShownSharedAlbumInfo() =>
provider.getBool(PrefKey.hasShownSharedAlbumInfo);
bool hasShownSharedAlbumInfoOr(bool def) => hasShownSharedAlbumInfo() ?? def;
Future<bool> setHasShownSharedAlbumInfo(bool value) =>
provider.setBool(PrefKey.hasShownSharedAlbumInfo, value);
final PrefProvider provider;
static Pref? _inst;
@ -314,6 +320,7 @@ enum PrefKey {
isSlideshowRepeat,
isAlbumBrowserShowDate,
gpsMapProvider,
hasShownSharedAlbumInfo,
}
extension on PrefKey {
@ -361,6 +368,8 @@ extension on PrefKey {
return "isAlbumBrowserShowDate";
case PrefKey.gpsMapProvider:
return "gpsMapProvider";
case PrefKey.hasShownSharedAlbumInfo:
return "hasShownSharedAlbumInfo";
}
}
}

View file

@ -40,6 +40,7 @@ import 'package:nc_photos/widget/photo_list_helper.dart';
import 'package:nc_photos/widget/photo_list_item.dart';
import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart';
import 'package:nc_photos/widget/share_album_dialog.dart';
import 'package:nc_photos/widget/shared_album_info_dialog.dart';
import 'package:nc_photos/widget/simple_input_dialog.dart';
import 'package:nc_photos/widget/viewer.dart';
@ -182,6 +183,10 @@ class _AlbumBrowserState extends State<AlbumBrowser>
final albumRepo = AlbumRepo(AlbumCachedDataSource(AppDb()));
final album = await albumRepo.get(widget.account, widget.album.albumFile!);
await _setAlbum(album);
if (album.shares?.isNotEmpty == true) {
_showSharedAlbumInfoDialog();
}
}
Widget _buildContent(BuildContext context) {
@ -329,6 +334,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
}
void _onSharePressed(BuildContext context) async {
await _showSharedAlbumInfoDialog();
await showDialog(
context: context,
builder: (_) => ShareAlbumDialog(
@ -778,6 +784,18 @@ class _AlbumBrowserState extends State<AlbumBrowser>
widget.account, album, items);
}
Future<void> _showSharedAlbumInfoDialog() {
if (!Pref().hasShownSharedAlbumInfoOr(false)) {
return showDialog(
context: context,
builder: (_) => const SharedAlbumInfoDialog(),
barrierDismissible: false,
);
} else {
return Future.value();
}
}
bool get _canRemoveSelection {
if (_album!.albumFile!.isOwned(widget.account.username) == true) {
return true;

View file

@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:nc_photos/app_localizations.dart';
import 'package:nc_photos/help_utils.dart' as help_utils;
import 'package:nc_photos/pref.dart';
import 'package:url_launcher/url_launcher.dart';
class SharedAlbumInfoDialog extends StatefulWidget {
const SharedAlbumInfoDialog({
Key? key,
}) : super(key: key);
@override
createState() => _SharedAlbumInfoDialogState();
}
class _SharedAlbumInfoDialogState extends State<SharedAlbumInfoDialog> {
@override
dispose() {
super.dispose();
Pref().setHasShownSharedAlbumInfo(true);
}
@override
build(BuildContext context) {
return AlertDialog(
title: Text(L10n.global().sharedAlbumInfoDialogTitle),
content: Text(L10n.global().sharedAlbumInfoDialogContent),
actions: [
TextButton(
onPressed: () => _onSkipPressed(context),
child: Text(L10n.global().skipButtonLabel),
),
TextButton(
onPressed: _onLearnMorePressed,
child: Text(L10n.global().learnMoreButtonLabel),
),
],
);
}
void _onSkipPressed(BuildContext context) {
Navigator.of(context).pop();
}
void _onLearnMorePressed() {
launch(help_utils.sharedAlbumLimitationsUrl);
Navigator.of(context).pop();
}
}