This commit is contained in:
parent
05f323665a
commit
d08fd52e51
@ -14,6 +14,7 @@ class Mount with ChangeNotifier {
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String? get bucket => mountConfig.bucket;
|
||||||
String get name => mountConfig.name;
|
String get name => mountConfig.name;
|
||||||
String get path => mountConfig.path;
|
String get path => mountConfig.path;
|
||||||
IconData? get state => mountConfig.state;
|
IconData? get state => mountConfig.state;
|
||||||
|
@ -4,6 +4,7 @@ import 'package:collection/collection.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:repertory/helpers.dart';
|
import 'package:repertory/helpers.dart';
|
||||||
|
import 'package:repertory/models/mount.dart';
|
||||||
import 'package:repertory/types/mount_config.dart';
|
import 'package:repertory/types/mount_config.dart';
|
||||||
|
|
||||||
class MountList with ChangeNotifier {
|
class MountList with ChangeNotifier {
|
||||||
@ -11,10 +12,10 @@ class MountList with ChangeNotifier {
|
|||||||
_fetch();
|
_fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MountConfig> _mountList = [];
|
List<Mount> _mountList = [];
|
||||||
|
|
||||||
UnmodifiableListView<MountConfig> get items =>
|
UnmodifiableListView<Mount> get items =>
|
||||||
UnmodifiableListView<MountConfig>(_mountList);
|
UnmodifiableListView<Mount>(_mountList);
|
||||||
|
|
||||||
bool hasBucketName(String mountType, String bucket, {String? excludeName}) {
|
bool hasBucketName(String mountType, String bucket, {String? excludeName}) {
|
||||||
final list = items.where(
|
final list = items.where(
|
||||||
@ -27,7 +28,7 @@ class MountList with ChangeNotifier {
|
|||||||
(item) =>
|
(item) =>
|
||||||
item.name.toLowerCase() == excludeName.toLowerCase(),
|
item.name.toLowerCase() == excludeName.toLowerCase(),
|
||||||
))
|
))
|
||||||
.firstWhereOrNull((MountConfig item) {
|
.firstWhereOrNull((Mount item) {
|
||||||
return item.bucket != null &&
|
return item.bucket != null &&
|
||||||
item.bucket!.toLowerCase() == bucket.toLowerCase();
|
item.bucket!.toLowerCase() == bucket.toLowerCase();
|
||||||
}) !=
|
}) !=
|
||||||
@ -50,11 +51,11 @@ class MountList with ChangeNotifier {
|
|||||||
if (response.statusCode != 200) {
|
if (response.statusCode != 200) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<MountConfig> nextList = [];
|
List<Mount> nextList = [];
|
||||||
|
|
||||||
jsonDecode(response.body).forEach((key, value) {
|
jsonDecode(response.body).forEach((key, value) {
|
||||||
nextList.addAll(
|
nextList.addAll(
|
||||||
value.map((name) => MountConfig.fromJson(key, name)).toList(),
|
value.map((name) => Mount(MountConfig.fromJson(key, name))).toList(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
_sort(nextList);
|
_sort(nextList);
|
||||||
@ -90,9 +91,6 @@ class MountList with ChangeNotifier {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
_mountList = [];
|
|
||||||
notifyListeners();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('$e');
|
debugPrint('$e');
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:repertory/constants.dart' as constants;
|
import 'package:repertory/constants.dart' as constants;
|
||||||
import 'package:repertory/models/mount.dart';
|
|
||||||
import 'package:repertory/models/mount_list.dart';
|
import 'package:repertory/models/mount_list.dart';
|
||||||
import 'package:repertory/widgets/mount_widget.dart';
|
import 'package:repertory/widgets/mount_widget.dart';
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ class MountListWidget extends StatelessWidget {
|
|||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
return ChangeNotifierProvider(
|
return ChangeNotifierProvider(
|
||||||
create: (context) => Mount(mountList.items[idx]),
|
create: (context) => mountList.items[idx],
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom:
|
bottom:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user