UI: Move remove link option insided manage link
This commit is contained in:
parent
d73ef88b66
commit
9740c7f8b3
|
@ -9,7 +9,9 @@ import 'package:flutter_sodium/flutter_sodium.dart';
|
||||||
import 'package:photos/ente_theme_data.dart';
|
import 'package:photos/ente_theme_data.dart';
|
||||||
import 'package:photos/models/collection.dart';
|
import 'package:photos/models/collection.dart';
|
||||||
import 'package:photos/services/collections_service.dart';
|
import 'package:photos/services/collections_service.dart';
|
||||||
|
import 'package:photos/theme/colors.dart';
|
||||||
import 'package:photos/theme/ente_theme.dart';
|
import 'package:photos/theme/ente_theme.dart';
|
||||||
|
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
|
||||||
import 'package:photos/ui/common/dialogs.dart';
|
import 'package:photos/ui/common/dialogs.dart';
|
||||||
import 'package:photos/ui/components/captioned_text_widget.dart';
|
import 'package:photos/ui/components/captioned_text_widget.dart';
|
||||||
import 'package:photos/ui/components/divider_widget.dart';
|
import 'package:photos/ui/components/divider_widget.dart';
|
||||||
|
@ -45,6 +47,8 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
|
||||||
|
|
||||||
Tuple3<int, String, int> _selectedExpiry;
|
Tuple3<int, String, int> _selectedExpiry;
|
||||||
int _selectedDeviceLimitIndex = 0;
|
int _selectedDeviceLimitIndex = 0;
|
||||||
|
final CollectionSharingActions sharingActions =
|
||||||
|
CollectionSharingActions(CollectionsService.instance);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -55,7 +59,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final enteColorScheme = getEnteColorScheme(context);
|
final enteColorScheme = getEnteColorScheme(context);
|
||||||
final int validTill = widget.collection.publicURLs?.first?.validTill ?? 0;
|
final int validTill = widget.collection?.publicURLs?.first?.validTill ?? 0;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Theme.of(context).backgroundColor,
|
backgroundColor: Theme.of(context).backgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
@ -193,6 +197,30 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 24,
|
||||||
|
),
|
||||||
|
MenuItemWidget(
|
||||||
|
captionedTextWidget: const CaptionedTextWidget(
|
||||||
|
title: "Remove link",
|
||||||
|
textColor: warning500,
|
||||||
|
),
|
||||||
|
leadingIcon: Icons.remove_circle_outline,
|
||||||
|
leadingIconColor: warning500,
|
||||||
|
menuItemColor: getEnteColorScheme(context).fillFaint,
|
||||||
|
pressedColor: getEnteColorScheme(context).fillFaint,
|
||||||
|
onTap: () async {
|
||||||
|
final bool result = await sharingActions.publicLinkToggle(
|
||||||
|
context,
|
||||||
|
widget.collection,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
if (result && mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
// setState(() => {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -12,9 +12,8 @@ import 'package:photos/models/collection.dart';
|
||||||
import 'package:photos/models/public_key.dart';
|
import 'package:photos/models/public_key.dart';
|
||||||
import 'package:photos/services/collections_service.dart';
|
import 'package:photos/services/collections_service.dart';
|
||||||
import 'package:photos/services/user_service.dart';
|
import 'package:photos/services/user_service.dart';
|
||||||
import 'package:photos/theme/colors.dart';
|
|
||||||
import 'package:photos/theme/ente_theme.dart';
|
import 'package:photos/theme/ente_theme.dart';
|
||||||
import 'package:photos/ui/common/dialogs.dart';
|
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
|
||||||
import 'package:photos/ui/common/gradient_button.dart';
|
import 'package:photos/ui/common/gradient_button.dart';
|
||||||
import 'package:photos/ui/common/loading_widget.dart';
|
import 'package:photos/ui/common/loading_widget.dart';
|
||||||
import 'package:photos/ui/components/captioned_text_widget.dart';
|
import 'package:photos/ui/components/captioned_text_widget.dart';
|
||||||
|
@ -43,6 +42,8 @@ class _SharingDialogState extends State<SharingDialog> {
|
||||||
List<User> _sharees;
|
List<User> _sharees;
|
||||||
String _email;
|
String _email;
|
||||||
final Logger _logger = Logger("SharingDialogState");
|
final Logger _logger = Logger("SharingDialogState");
|
||||||
|
final CollectionSharingActions sharingActions =
|
||||||
|
CollectionSharingActions(CollectionsService.instance);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -155,26 +156,14 @@ class _SharingDialogState extends State<SharingDialog> {
|
||||||
routeToPage(
|
routeToPage(
|
||||||
context,
|
context,
|
||||||
ManageSharedLinkWidget(collection: widget.collection),
|
ManageSharedLinkWidget(collection: widget.collection),
|
||||||
|
).then(
|
||||||
|
(value) => {
|
||||||
|
if (mounted) {setState(() => {})}
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
isTopBorderRadiusRemoved: true,
|
isTopBorderRadiusRemoved: true,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
height: 24,
|
|
||||||
),
|
|
||||||
MenuItemWidget(
|
|
||||||
captionedTextWidget: const CaptionedTextWidget(
|
|
||||||
title: "Remove link",
|
|
||||||
textColor: warning500,
|
|
||||||
),
|
|
||||||
leadingIcon: Icons.remove_circle_outline,
|
|
||||||
leadingIconColor: warning500,
|
|
||||||
menuItemColor: getEnteColorScheme(context).fillFaint,
|
|
||||||
pressedColor: getEnteColorScheme(context).fillFaint,
|
|
||||||
onTap: () async {
|
|
||||||
await _publicLinkToggle(false);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -187,7 +176,14 @@ class _SharingDialogState extends State<SharingDialog> {
|
||||||
menuItemColor: getEnteColorScheme(context).fillFaint,
|
menuItemColor: getEnteColorScheme(context).fillFaint,
|
||||||
pressedColor: getEnteColorScheme(context).fillFaint,
|
pressedColor: getEnteColorScheme(context).fillFaint,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await _publicLinkToggle(true);
|
final bool result = await sharingActions.publicLinkToggle(
|
||||||
|
context,
|
||||||
|
widget.collection,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
if (result && mounted) {
|
||||||
|
setState(() => {});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -211,44 +207,6 @@ class _SharingDialogState extends State<SharingDialog> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _publicLinkToggle(bool enable) async {
|
|
||||||
// confirm if user wants to disable the url
|
|
||||||
if (!enable) {
|
|
||||||
final choice = await showChoiceDialog(
|
|
||||||
context,
|
|
||||||
'Remove public link?',
|
|
||||||
'This will remove the public link for accessing "${widget.collection.name}".',
|
|
||||||
firstAction: 'Yes, remove',
|
|
||||||
secondAction: 'Cancel',
|
|
||||||
actionType: ActionType.critical,
|
|
||||||
);
|
|
||||||
if (choice != DialogUserChoice.firstChoice) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final dialog = createProgressDialog(
|
|
||||||
context,
|
|
||||||
enable ? "Creating link..." : "Disabling link...",
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
await dialog.show();
|
|
||||||
enable
|
|
||||||
? await CollectionsService.instance.createShareUrl(widget.collection)
|
|
||||||
: await CollectionsService.instance
|
|
||||||
.disableShareUrl(widget.collection);
|
|
||||||
dialog.hide();
|
|
||||||
setState(() {});
|
|
||||||
} catch (e) {
|
|
||||||
dialog.hide();
|
|
||||||
if (e is SharingNotPermittedForFreeAccountsError) {
|
|
||||||
_showUnSupportedAlert();
|
|
||||||
} else {
|
|
||||||
_logger.severe("failed to share collection", e);
|
|
||||||
showGenericErrorDialog(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _getEmailField() {
|
Widget _getEmailField() {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.fromLTRB(8, 0, 8, 0),
|
padding: const EdgeInsets.fromLTRB(8, 0, 8, 0),
|
||||||
|
|
Loading…
Reference in a new issue