Skip to content

Commit 603e523

Browse files
committed
Minor meta refactoring and renaming
1 parent 63c6704 commit 603e523

File tree

10 files changed

+113
-100
lines changed

10 files changed

+113
-100
lines changed

lib/flutter_map_tile_caching.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,23 @@ import 'src/bulk_download/instance.dart';
3535
import 'src/bulk_download/rate_limited_stream.dart';
3636
import 'src/bulk_download/tile_loops/shared.dart';
3737
import 'src/misc/int_extremes.dart';
38-
import 'src/providers/browsing_errors.dart';
38+
import 'src/providers/image_provider/browsing_errors.dart';
3939

4040
export 'src/backend/export_external.dart';
41-
export 'src/providers/browsing_errors.dart';
41+
export 'src/providers/image_provider/browsing_errors.dart';
4242

4343
part 'src/bulk_download/control_cmds.dart';
4444
part 'src/bulk_download/download_progress.dart';
4545
part 'src/bulk_download/manager.dart';
4646
part 'src/bulk_download/thread.dart';
4747
part 'src/bulk_download/tile_event.dart';
48-
part 'src/providers/allowed_notify_value_notifier.dart';
49-
part 'src/providers/image_provider.dart';
50-
part 'src/providers/internal_get_bytes.dart';
51-
part 'src/providers/tile_provider.dart';
52-
part 'src/providers/tile_provider_settings.dart';
48+
part 'src/providers/debugger/allowed_notify_value_notifier.dart';
49+
part 'src/providers/debugger/debugger.dart';
50+
part 'src/providers/image_provider/image_provider.dart';
51+
part 'src/providers/image_provider/internal_get_bytes.dart';
52+
part 'src/providers/tile_provider/behaviours.dart';
53+
part 'src/providers/tile_provider/tile_provider.dart';
54+
part 'src/providers/tile_provider/tile_provider_settings.dart';
5355
part 'src/regions/base_region.dart';
5456
part 'src/regions/circle.dart';
5557
part 'src/regions/custom_polygon.dart';

lib/src/providers/allowed_notify_value_notifier.dart renamed to lib/src/providers/debugger/allowed_notify_value_notifier.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright © Luka S (JaffaKetchup) under GPL-v3
22
// A full license can be found at .\LICENSE
33

4-
part of '../../flutter_map_tile_caching.dart';
4+
part of '../../../flutter_map_tile_caching.dart';
55

66
class _AllowedNotifyValueNotifier<T> extends ValueNotifier<T> {
77
_AllowedNotifyValueNotifier(super._value);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright © Luka S (JaffaKetchup) under GPL-v3
2+
// A full license can be found at .\LICENSE
3+
4+
part of '../../../flutter_map_tile_caching.dart';
5+
6+
typedef TileLoadingDebugMap = Map<TileCoordinates, TileLoadingDebugInfo>;
7+
8+
class TileLoadingDebugInfo {
9+
TileLoadingDebugInfo._();
10+
11+
/// Indicates whether the tile completed loading successfully
12+
///
13+
/// * `true`: completed
14+
/// * `false`: errored
15+
late final bool didComplete;
16+
}

lib/src/providers/browsing_errors.dart renamed to lib/src/providers/image_provider/browsing_errors.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:http/http.dart';
66
import 'package:http/io_client.dart';
77
import 'package:meta/meta.dart';
88

9-
import '../../flutter_map_tile_caching.dart';
9+
import '../../../flutter_map_tile_caching.dart';
1010

1111
/// An [Exception] indicating that there was an error retrieving tiles to be
1212
/// displayed on the map

lib/src/providers/image_provider.dart renamed to lib/src/providers/image_provider/image_provider.dart

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
// Copyright © Luka S (JaffaKetchup) under GPL-v3
22
// A full license can be found at .\LICENSE
33

4-
part of '../../flutter_map_tile_caching.dart';
5-
6-
class DebugNotifierInfo {
7-
DebugNotifierInfo._();
8-
9-
/// Indicates whether the tile completed loading successfully
10-
///
11-
/// * `true`: completed
12-
/// * `false`: errored
13-
late final bool didComplete;
14-
}
4+
part of '../../../flutter_map_tile_caching.dart';
155

166
/// A specialised [ImageProvider] that uses FMTC internals to enable browse
177
/// caching
@@ -130,7 +120,7 @@ class _FMTCImageProvider extends ImageProvider<_FMTCImageProvider> {
130120
void Function()? finishedLoadingBytes,
131121
bool requireValidImage = false,
132122
}) async {
133-
final currentTileDebugNotifierInfo = DebugNotifierInfo._();
123+
final currentTileDebugNotifierInfo = TileLoadingDebugInfo._();
134124

135125
void close({required bool didComplete}) {
136126
finishedLoadingBytes?.call();

lib/src/providers/internal_get_bytes.dart renamed to lib/src/providers/image_provider/internal_get_bytes.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Copyright © Luka S (JaffaKetchup) under GPL-v3
22
// A full license can be found at .\LICENSE
33

4-
part of '../../flutter_map_tile_caching.dart';
4+
part of '../../../flutter_map_tile_caching.dart';
55

66
Future<Uint8List> _internalGetBytes({
77
required TileCoordinates coords,
88
required TileLayer options,
99
required FMTCTileProvider provider,
1010
required StreamController<ImageChunkEvent>? chunkEvents,
1111
required bool requireValidImage,
12-
required DebugNotifierInfo currentTileDebugNotifierInfo, // TODO
12+
required TileLoadingDebugInfo currentTileDebugNotifierInfo, // TODO
1313
}) async {
1414
void registerHit(List<String> storeNames) {
1515
if (provider.settings.recordHitsAndMisses) {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright © Luka S (JaffaKetchup) under GPL-v3
2+
// A full license can be found at .\LICENSE
3+
4+
part of '../../../flutter_map_tile_caching.dart';
5+
6+
/// Alias of [CacheBehavior]
7+
///
8+
/// ... with the correct spelling :D
9+
typedef CacheBehaviour = CacheBehavior;
10+
11+
/// Behaviours dictating how and when browse caching should occur
12+
///
13+
/// | `CacheBehavior` | Preferred fetch method | Fallback fetch method |
14+
/// |--------------------------|------------------------|-----------------------|
15+
/// | `cacheOnly` | Cache | None |
16+
/// | `cacheFirst` | Cache | Network |
17+
/// | `onlineFirst` | Network | Cache |
18+
/// | *Standard Tile Provider* | *Network* | *None* |
19+
enum CacheBehavior {
20+
/// Only fetch tiles from the local cache
21+
///
22+
/// In this mode, [StoreReadWriteBehavior] is irrelevant.
23+
///
24+
/// Throws [FMTCBrowsingErrorType.missingInCacheOnlyMode] if a tile is
25+
/// unavailable.
26+
///
27+
/// See documentation on [CacheBehavior] for behavior comparison table.
28+
cacheOnly,
29+
30+
/// Fetch tiles from the cache, falling back to the network to fetch and
31+
/// create/update non-existent/expired tiles, dependent on the selected
32+
/// [StoreReadWriteBehavior]
33+
///
34+
/// See documentation on [CacheBehavior] for behavior comparison table.
35+
cacheFirst,
36+
37+
/// Fetch and create/update non-existent/expired tiles from the network,
38+
/// falling back to the cache to fetch tiles, dependent on the selected
39+
/// [StoreReadWriteBehavior]
40+
///
41+
/// See documentation on [CacheBehavior] for behavior comparison table.
42+
onlineFirst,
43+
}
44+
45+
/// Alias of [StoreReadWriteBehavior]
46+
///
47+
/// ... with the correct spelling :D
48+
typedef StoreReadWriteBehaviour = StoreReadWriteBehavior;
49+
50+
/// Determines the read/update/create tile behaviour of a store
51+
enum StoreReadWriteBehavior {
52+
/// Only read tiles
53+
read,
54+
55+
/// Read tiles, and also update existing tiles
56+
///
57+
/// Unlike 'create', if (an older version of) a tile does not already exist in
58+
/// the store, it will not be written.
59+
readUpdate,
60+
61+
/// Read, update, and create tiles
62+
///
63+
/// See [readUpdate] for a definition of 'update'.
64+
readUpdateCreate,
65+
}

lib/src/providers/tile_provider.dart renamed to lib/src/providers/tile_provider/tile_provider.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright © Luka S (JaffaKetchup) under GPL-v3
22
// A full license can be found at .\LICENSE
33

4-
part of '../../flutter_map_tile_caching.dart';
4+
part of '../../../flutter_map_tile_caching.dart';
55

66
/// Specialised [TileProvider] that uses a specialised [ImageProvider] to connect
77
/// to FMTC internals and enable advanced caching/retrieval logic
@@ -44,7 +44,8 @@ class FMTCTileProvider extends TileProvider {
4444
FMTCTileProvider.allStores({
4545
required StoreReadWriteBehavior allStoresConfiguration,
4646
FMTCTileProviderSettings? settings,
47-
ValueNotifier<Map<TileCoordinates, DebugNotifierInfo>>? tileLoadingDebugger,
47+
ValueNotifier<Map<TileCoordinates, TileLoadingDebugInfo>>?
48+
tileLoadingDebugger,
4849
Map<String, String>? headers,
4950
http.Client? httpClient,
5051
}) : this.multipleStores(
@@ -90,6 +91,9 @@ class FMTCTileProvider extends TileProvider {
9091
/// Defaults to a standard [IOClient]/[HttpClient].
9192
final http.Client httpClient;
9293

94+
final ValueNotifier<Map<TileCoordinates, TileLoadingDebugInfo>>?
95+
tileLoadingDebugger;
96+
9397
/// Each [Completer] is completed once the corresponding tile has finished
9498
/// loading
9599
///
@@ -99,13 +103,9 @@ class FMTCTileProvider extends TileProvider {
99103
/// Does not include tiles loaded from session cache.
100104
final _tilesInProgress = HashMap<TileCoordinates, Completer<void>>();
101105

102-
final ValueNotifier<Map<TileCoordinates, DebugNotifierInfo>>?
103-
tileLoadingDebugger;
104-
105-
_AllowedNotifyValueNotifier<Map<TileCoordinates, DebugNotifierInfo>>?
106-
get _internalTileLoadingDebugger =>
107-
tileLoadingDebugger as _AllowedNotifyValueNotifier<
108-
Map<TileCoordinates, DebugNotifierInfo>>?;
106+
_AllowedNotifyValueNotifier<TileLoadingDebugMap>?
107+
get _internalTileLoadingDebugger => tileLoadingDebugger
108+
as _AllowedNotifyValueNotifier<TileLoadingDebugMap>?;
109109

110110
@override
111111
ImageProvider getImage(TileCoordinates coordinates, TileLayer options) =>

lib/src/providers/tile_provider_settings.dart renamed to lib/src/providers/tile_provider/tile_provider_settings.dart

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,7 @@
11
// Copyright © Luka S (JaffaKetchup) under GPL-v3
22
// A full license can be found at .\LICENSE
33

4-
part of '../../flutter_map_tile_caching.dart';
5-
6-
/// Callback type that takes an [FMTCBrowsingError] exception
7-
typedef FMTCBrowsingErrorHandler = Uint8List? Function(
8-
FMTCBrowsingError exception,
9-
);
10-
11-
/// Alias of [CacheBehavior]
12-
///
13-
/// ... with the correct spelling :D
14-
typedef CacheBehaviour = CacheBehavior;
15-
16-
/// Behaviours dictating how and when browse caching should occur
17-
///
18-
/// | `CacheBehavior` | Preferred fetch method | Fallback fetch method |
19-
/// |--------------------------|------------------------|-----------------------|
20-
/// | `cacheOnly` | Cache | None |
21-
/// | `cacheFirst` | Cache | Network |
22-
/// | `onlineFirst` | Network | Cache |
23-
/// | *Standard Tile Provider* | *Network* | *None* |
24-
enum CacheBehavior {
25-
/// Only fetch tiles from the local cache
26-
///
27-
/// In this mode, [StoreReadWriteBehavior] is irrelevant.
28-
///
29-
/// Throws [FMTCBrowsingErrorType.missingInCacheOnlyMode] if a tile is
30-
/// unavailable.
31-
///
32-
/// See documentation on [CacheBehavior] for behavior comparison table.
33-
cacheOnly,
34-
35-
/// Fetch tiles from the cache, falling back to the network to fetch and
36-
/// create/update non-existent/expired tiles, dependent on the selected
37-
/// [StoreReadWriteBehavior]
38-
///
39-
/// See documentation on [CacheBehavior] for behavior comparison table.
40-
cacheFirst,
41-
42-
/// Fetch and create/update non-existent/expired tiles from the network,
43-
/// falling back to the cache to fetch tiles, dependent on the selected
44-
/// [StoreReadWriteBehavior]
45-
///
46-
/// See documentation on [CacheBehavior] for behavior comparison table.
47-
onlineFirst,
48-
}
49-
50-
/// Alias of [StoreReadWriteBehavior]
51-
///
52-
/// ... with the correct spelling :D
53-
typedef StoreReadWriteBehaviour = StoreReadWriteBehavior;
54-
55-
/// Determines the read/update/create tile behaviour of a store
56-
enum StoreReadWriteBehavior {
57-
/// Only read tiles
58-
read,
59-
60-
/// Read tiles, and also update existing tiles
61-
///
62-
/// Unlike 'create', if (an older version of) a tile does not already exist in
63-
/// the store, it will not be written.
64-
readUpdate,
65-
66-
/// Read, update, and create tiles
67-
///
68-
/// See [readUpdate] for a definition of 'update'.
69-
readUpdateCreate,
70-
}
4+
part of '../../../flutter_map_tile_caching.dart';
715

726
/// Settings for an [FMTCTileProvider]
737
///
@@ -274,3 +208,8 @@ class FMTCTileProviderSettings {
274208
errorHandler,
275209
]);
276210
}
211+
212+
/// Callback type that takes an [FMTCBrowsingError] exception
213+
typedef FMTCBrowsingErrorHandler = Uint8List? Function(
214+
FMTCBrowsingError exception,
215+
);

lib/src/store/store.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class FMTCStore {
5050
StoreReadWriteBehavior.readUpdateCreate,
5151
StoreReadWriteBehavior? otherStoresBehavior,
5252
FMTCTileProviderSettings? settings,
53-
ValueNotifier<Map<TileCoordinates, DebugNotifierInfo>>? tileLoadingDebugger,
53+
ValueNotifier<Map<TileCoordinates, TileLoadingDebugInfo>>?
54+
tileLoadingDebugger,
5455
Map<String, String>? headers,
5556
http.Client? httpClient,
5657
}) =>

0 commit comments

Comments
 (0)