|
@@ -72,11 +72,13 @@ class ItemsWidget extends StatefulWidget {
|
|
|
|
|
|
class _ItemsWidgetState extends State<ItemsWidget> {
|
|
class _ItemsWidgetState extends State<ItemsWidget> {
|
|
late int currentDeviceLimit;
|
|
late int currentDeviceLimit;
|
|
|
|
+ late int initialDeviceLimit;
|
|
List<Widget> items = [];
|
|
List<Widget> items = [];
|
|
bool isCustomLimit = false;
|
|
bool isCustomLimit = false;
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
currentDeviceLimit = widget.collection.publicURLs!.first!.deviceLimit;
|
|
currentDeviceLimit = widget.collection.publicURLs!.first!.deviceLimit;
|
|
|
|
+ initialDeviceLimit = currentDeviceLimit;
|
|
if (!deviceLimits.contains(currentDeviceLimit)) {
|
|
if (!deviceLimits.contains(currentDeviceLimit)) {
|
|
isCustomLimit = true;
|
|
isCustomLimit = true;
|
|
}
|
|
}
|
|
@@ -88,43 +90,12 @@ class _ItemsWidgetState extends State<ItemsWidget> {
|
|
items.clear();
|
|
items.clear();
|
|
if (isCustomLimit) {
|
|
if (isCustomLimit) {
|
|
items.add(
|
|
items.add(
|
|
- MenuItemWidget(
|
|
|
|
- key: ValueKey(currentDeviceLimit),
|
|
|
|
- menuItemColor: getEnteColorScheme(context).fillFaint,
|
|
|
|
- captionedTextWidget: CaptionedTextWidget(
|
|
|
|
- title: "$currentDeviceLimit",
|
|
|
|
- ),
|
|
|
|
- trailingIcon: Icons.check,
|
|
|
|
- alignCaptionedTextToLeft: true,
|
|
|
|
- isTopBorderRadiusRemoved: true,
|
|
|
|
- isBottomBorderRadiusRemoved: true,
|
|
|
|
- ),
|
|
|
|
|
|
+ _menuItemForPicker(initialDeviceLimit),
|
|
);
|
|
);
|
|
- isCustomLimit = false;
|
|
|
|
}
|
|
}
|
|
for (int deviceLimit in deviceLimits) {
|
|
for (int deviceLimit in deviceLimits) {
|
|
items.add(
|
|
items.add(
|
|
- MenuItemWidget(
|
|
|
|
- key: ValueKey(deviceLimit),
|
|
|
|
- menuItemColor: getEnteColorScheme(context).fillFaint,
|
|
|
|
- captionedTextWidget: CaptionedTextWidget(
|
|
|
|
- title: "$deviceLimit",
|
|
|
|
- ),
|
|
|
|
- trailingIcon: currentDeviceLimit == deviceLimit ? Icons.check : null,
|
|
|
|
- alignCaptionedTextToLeft: true,
|
|
|
|
- isTopBorderRadiusRemoved: true,
|
|
|
|
- isBottomBorderRadiusRemoved: true,
|
|
|
|
- showOnlyLoadingState: true,
|
|
|
|
- onTap: () async {
|
|
|
|
- await _updateUrlSettings(context, {
|
|
|
|
- 'deviceLimit': deviceLimit,
|
|
|
|
- }).then(
|
|
|
|
- (value) => setState(() {
|
|
|
|
- currentDeviceLimit = deviceLimit;
|
|
|
|
- }),
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
|
|
+ _menuItemForPicker(deviceLimit),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
items = addSeparators(
|
|
items = addSeparators(
|
|
@@ -140,6 +111,30 @@ class _ItemsWidgetState extends State<ItemsWidget> {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Widget _menuItemForPicker(int deviceLimit) {
|
|
|
|
+ return MenuItemWidget(
|
|
|
|
+ key: ValueKey(deviceLimit),
|
|
|
|
+ menuItemColor: getEnteColorScheme(context).fillFaint,
|
|
|
|
+ captionedTextWidget: CaptionedTextWidget(
|
|
|
|
+ title: "$deviceLimit",
|
|
|
|
+ ),
|
|
|
|
+ trailingIcon: currentDeviceLimit == deviceLimit ? Icons.check : null,
|
|
|
|
+ alignCaptionedTextToLeft: true,
|
|
|
|
+ isTopBorderRadiusRemoved: true,
|
|
|
|
+ isBottomBorderRadiusRemoved: true,
|
|
|
|
+ showOnlyLoadingState: true,
|
|
|
|
+ onTap: () async {
|
|
|
|
+ await _updateUrlSettings(context, {
|
|
|
|
+ 'deviceLimit': deviceLimit,
|
|
|
|
+ }).then(
|
|
|
|
+ (value) => setState(() {
|
|
|
|
+ currentDeviceLimit = deviceLimit;
|
|
|
|
+ }),
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
Future<void> _updateUrlSettings(
|
|
Future<void> _updateUrlSettings(
|
|
BuildContext context,
|
|
BuildContext context,
|
|
Map<String, dynamic> prop,
|
|
Map<String, dynamic> prop,
|