Removed old code
This commit is contained in:
parent
bff5d91a3d
commit
f078abc2d6
1 changed files with 0 additions and 166 deletions
|
@ -4,9 +4,7 @@ import 'dart:typed_data';
|
|||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
||||
import 'package:flutter_sodium/flutter_sodium.dart';
|
||||
import 'package:photos/ente_theme_data.dart';
|
||||
import 'package:photos/models/collection.dart';
|
||||
import 'package:photos/services/collections_service.dart';
|
||||
import 'package:photos/theme/colors.dart';
|
||||
|
@ -23,7 +21,6 @@ import 'package:photos/utils/date_time_util.dart';
|
|||
import 'package:photos/utils/dialog_util.dart';
|
||||
import 'package:photos/utils/navigation_util.dart';
|
||||
import 'package:photos/utils/toast_util.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class ManageSharedLinkWidget extends StatefulWidget {
|
||||
final Collection? collection;
|
||||
|
@ -35,25 +32,11 @@ class ManageSharedLinkWidget extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
|
||||
// index, title, milliseconds in future post which link should expire (when >0)
|
||||
final List<Tuple3<int, String, int>> _expiryOptions = [
|
||||
const Tuple3(0, "Never", 0),
|
||||
Tuple3(1, "After 1 hour", const Duration(hours: 1).inMicroseconds),
|
||||
Tuple3(2, "After 1 day", const Duration(days: 1).inMicroseconds),
|
||||
Tuple3(3, "After 1 week", const Duration(days: 7).inMicroseconds),
|
||||
// todo: make this time calculation perfect
|
||||
Tuple3(4, "After 1 month", const Duration(days: 30).inMicroseconds),
|
||||
Tuple3(5, "After 1 year", const Duration(days: 365).inMicroseconds),
|
||||
const Tuple3(6, "Custom", -1),
|
||||
];
|
||||
|
||||
late Tuple3<int, String, int> _selectedExpiry;
|
||||
final CollectionActions sharingActions =
|
||||
CollectionActions(CollectionsService.instance);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_selectedExpiry = _expiryOptions.first;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
@ -116,7 +99,6 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
|
|||
menuItemColor: enteColorScheme.fillFaint,
|
||||
surfaceExecutionStates: false,
|
||||
onTap: () async {
|
||||
// await showPicker();
|
||||
routeToPage(
|
||||
context,
|
||||
LinkExpiryPickerPage(widget.collection!),
|
||||
|
@ -244,7 +226,6 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
|
|||
);
|
||||
if (result && mounted) {
|
||||
Navigator.of(context).pop();
|
||||
// setState(() => {});
|
||||
}
|
||||
},
|
||||
),
|
||||
|
@ -257,153 +238,6 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> showPicker() async {
|
||||
return showCupertinoModalPopup(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.cupertinoPickerTopColor,
|
||||
border: const Border(
|
||||
bottom: BorderSide(
|
||||
color: Color(0xff999999),
|
||||
width: 0.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
CupertinoButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop('cancel');
|
||||
},
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0,
|
||||
vertical: 5.0,
|
||||
),
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
),
|
||||
CupertinoButton(
|
||||
onPressed: () async {
|
||||
int newValidTill = -1;
|
||||
bool hasSelectedCustom = false;
|
||||
final int expireAfterInMicroseconds =
|
||||
_selectedExpiry.item3;
|
||||
// need to manually select time
|
||||
if (expireAfterInMicroseconds < 0) {
|
||||
hasSelectedCustom = true;
|
||||
Navigator.of(context).pop('');
|
||||
final timeInMicrosecondsFromEpoch =
|
||||
await _showDateTimePicker();
|
||||
if (timeInMicrosecondsFromEpoch != null) {
|
||||
newValidTill = timeInMicrosecondsFromEpoch;
|
||||
}
|
||||
} else if (expireAfterInMicroseconds == 0) {
|
||||
// no expiry
|
||||
newValidTill = 0;
|
||||
} else {
|
||||
newValidTill = DateTime.now().microsecondsSinceEpoch +
|
||||
expireAfterInMicroseconds;
|
||||
}
|
||||
if (!hasSelectedCustom) {
|
||||
Navigator.of(context).pop('');
|
||||
}
|
||||
if (newValidTill >= 0) {
|
||||
debugPrint("Setting expirty $newValidTill");
|
||||
await updateTime(newValidTill);
|
||||
}
|
||||
},
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0,
|
||||
vertical: 2.0,
|
||||
),
|
||||
child: Text(
|
||||
'Confirm',
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 220.0,
|
||||
color: const Color(0xfff7f7f7),
|
||||
child: CupertinoPicker(
|
||||
backgroundColor:
|
||||
Theme.of(context).backgroundColor.withOpacity(0.95),
|
||||
onSelectedItemChanged: (value) {
|
||||
final firstWhere = _expiryOptions
|
||||
.firstWhere((element) => element.item1 == value);
|
||||
setState(() {
|
||||
_selectedExpiry = firstWhere;
|
||||
});
|
||||
},
|
||||
magnification: 1.3,
|
||||
useMagnifier: true,
|
||||
itemExtent: 25,
|
||||
diameterRatio: 1,
|
||||
children: _expiryOptions
|
||||
.map(
|
||||
(e) => Text(
|
||||
e.item2,
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateTime(int newValidTill) async {
|
||||
await _updateUrlSettings(
|
||||
context,
|
||||
{'validTill': newValidTill},
|
||||
);
|
||||
if (mounted) {
|
||||
// reset to default value. THis is needed will we move to
|
||||
// new selection menu as per figma/
|
||||
_selectedExpiry = _expiryOptions.first;
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
// _showDateTimePicker return null if user doesn't select date-time
|
||||
Future<int?> _showDateTimePicker() async {
|
||||
final dateResult = await DatePicker.showDatePicker(
|
||||
context,
|
||||
minTime: DateTime.now(),
|
||||
currentTime: DateTime.now(),
|
||||
locale: LocaleType.en,
|
||||
theme: Theme.of(context).colorScheme.dateTimePickertheme,
|
||||
);
|
||||
if (dateResult == null) {
|
||||
return null;
|
||||
}
|
||||
final dateWithTimeResult = await DatePicker.showTime12hPicker(
|
||||
context,
|
||||
showTitleActions: true,
|
||||
currentTime: dateResult,
|
||||
locale: LocaleType.en,
|
||||
theme: Theme.of(context).colorScheme.dateTimePickertheme,
|
||||
);
|
||||
if (dateWithTimeResult == null) {
|
||||
return null;
|
||||
} else {
|
||||
return dateWithTimeResult.microsecondsSinceEpoch;
|
||||
}
|
||||
}
|
||||
|
||||
final TextEditingController _textFieldController = TextEditingController();
|
||||
|
||||
Future<String?> _displayLinkPasswordInput(BuildContext context) async {
|
||||
|
|
Loading…
Add table
Reference in a new issue