diff --git a/app/lib/app_router.dart b/app/lib/app_router.dart index 0a1ec7401e..9374d47ed9 100644 --- a/app/lib/app_router.dart +++ b/app/lib/app_router.dart @@ -2,6 +2,7 @@ import "dart:async"; import "package:auto_route/auto_route.dart"; import "package:flutter/material.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:riverpod_annotation/riverpod_annotation.dart"; import "package:typewriter/guard/connected_guard.dart"; import "package:typewriter/models/page.dart"; @@ -85,7 +86,7 @@ class InvalidatorNavigatorObserver extends NavigatorObserver { /// Provides the current route data for the given [name]. @Riverpod(keepAlive: true) -RouteData? currentRouteData(CurrentRouteDataRef ref, String path) { +RouteData? currentRouteData(Ref ref, String path) { final router = ref.watch(appRouter); return _fetchCurrentRouteData(path, router); } diff --git a/app/lib/app_router.g.dart b/app/lib/app_router.g.dart index a6fba098c9..ad6c5192a6 100644 --- a/app/lib/app_router.g.dart +++ b/app/lib/app_router.g.dart @@ -6,7 +6,7 @@ part of 'app_router.dart'; // RiverpodGenerator // ************************************************************************** -String _$currentRouteDataHash() => r'85f6e480f36835de3b5fb961a26cce4215ee98aa'; +String _$currentRouteDataHash() => r'bc5d43d37915bc2ee1b3bd06af8a8f9f45cdb5ac'; /// Copied from Dart SDK class _SystemHash { diff --git a/app/lib/models/communicator.dart b/app/lib/models/communicator.dart index 604ebc22f4..dab9209d65 100644 --- a/app/lib/models/communicator.dart +++ b/app/lib/models/communicator.dart @@ -41,7 +41,7 @@ final socketProvider = StateNotifierProvider( class SocketNotifier extends StateNotifier { SocketNotifier(this.ref) : super(null); - final StateNotifierProviderRef ref; + final Ref ref; bool _disposed = false; /// When a socket gets disconnected, we want to try to reconnect it. @@ -227,13 +227,13 @@ class SocketNotifier extends StateNotifier { } @Riverpod(keepAlive: true) -Communicator communicator(CommunicatorRef ref) => Communicator(ref); +Communicator communicator(Ref ref) => Communicator(ref); @immutable class Communicator { const Communicator(this.ref); - final CommunicatorRef ref; + final Ref ref; Future fetchBook() async { final socket = ref.read(socketProvider); diff --git a/app/lib/models/communicator.g.dart b/app/lib/models/communicator.g.dart index 7d64d42ec1..99af6daf55 100644 --- a/app/lib/models/communicator.g.dart +++ b/app/lib/models/communicator.g.dart @@ -22,7 +22,7 @@ Map _$$ResponseImplToJson(_$ResponseImpl instance) => // RiverpodGenerator // ************************************************************************** -String _$communicatorHash() => r'9085b5b631ddf5d09d571a34e6d1de239259e08f'; +String _$communicatorHash() => r'31ea59bcbb12c56d2ec15a773434802d1e663753'; /// See also [communicator]. @ProviderFor(communicator) diff --git a/app/lib/models/entry.dart b/app/lib/models/entry.dart index e1a1c04302..0c9e0711e6 100644 --- a/app/lib/models/entry.dart +++ b/app/lib/models/entry.dart @@ -44,10 +44,19 @@ String? entryBlueprintId(Ref ref, String entryId) { return entry?.blueprintId; } +@riverpod +DeprecatedModifier? entryDeprecated(Ref ref, String entryId) { + final blueprintId = ref.watch(entryBlueprintIdProvider(entryId)); + if (blueprintId == null) return null; + final blueprint = ref.watch(entryBlueprintProvider(blueprintId)); + if (blueprint == null) return null; + return blueprint.modifiers.whereType().firstOrNull; +} + @riverpod bool isEntryDeprecated(Ref ref, String entryId) { - final entryTags = ref.watch(entryTagsProvider(entryId)); - return entryTags.contains("deprecated"); + final deprecated = ref.watch(entryDeprecatedProvider(entryId)); + return deprecated != null; } class EntryDefinition { @@ -120,7 +129,6 @@ class Entry { DataBlueprint? get genericBlueprint { if (_genericBlueprint != null) return _genericBlueprint; final genericBlueprint = data["_genericBlueprint"]; - print("Generic blueprint: $genericBlueprint"); if (genericBlueprint == null) return null; if (genericBlueprint is! Map) { diff --git a/app/lib/models/entry.g.dart b/app/lib/models/entry.g.dart index 63ba6241da..fa8b8b7785 100644 --- a/app/lib/models/entry.g.dart +++ b/app/lib/models/entry.g.dart @@ -417,7 +417,138 @@ class _EntryBlueprintIdProviderElement String get entryId => (origin as EntryBlueprintIdProvider).entryId; } -String _$isEntryDeprecatedHash() => r'f68cc9e8e0bf8eed671f49d5ceadc1d45e4da8a0'; +String _$entryDeprecatedHash() => r'379035c4bf36de1185ce43187253b02ea579eaa9'; + +/// See also [entryDeprecated]. +@ProviderFor(entryDeprecated) +const entryDeprecatedProvider = EntryDeprecatedFamily(); + +/// See also [entryDeprecated]. +class EntryDeprecatedFamily extends Family { + /// See also [entryDeprecated]. + const EntryDeprecatedFamily(); + + /// See also [entryDeprecated]. + EntryDeprecatedProvider call( + String entryId, + ) { + return EntryDeprecatedProvider( + entryId, + ); + } + + @override + EntryDeprecatedProvider getProviderOverride( + covariant EntryDeprecatedProvider provider, + ) { + return call( + provider.entryId, + ); + } + + static const Iterable? _dependencies = null; + + @override + Iterable? get dependencies => _dependencies; + + static const Iterable? _allTransitiveDependencies = null; + + @override + Iterable? get allTransitiveDependencies => + _allTransitiveDependencies; + + @override + String? get name => r'entryDeprecatedProvider'; +} + +/// See also [entryDeprecated]. +class EntryDeprecatedProvider extends AutoDisposeProvider { + /// See also [entryDeprecated]. + EntryDeprecatedProvider( + String entryId, + ) : this._internal( + (ref) => entryDeprecated( + ref as EntryDeprecatedRef, + entryId, + ), + from: entryDeprecatedProvider, + name: r'entryDeprecatedProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') + ? null + : _$entryDeprecatedHash, + dependencies: EntryDeprecatedFamily._dependencies, + allTransitiveDependencies: + EntryDeprecatedFamily._allTransitiveDependencies, + entryId: entryId, + ); + + EntryDeprecatedProvider._internal( + super._createNotifier, { + required super.name, + required super.dependencies, + required super.allTransitiveDependencies, + required super.debugGetCreateSourceHash, + required super.from, + required this.entryId, + }) : super.internal(); + + final String entryId; + + @override + Override overrideWith( + DeprecatedModifier? Function(EntryDeprecatedRef provider) create, + ) { + return ProviderOverride( + origin: this, + override: EntryDeprecatedProvider._internal( + (ref) => create(ref as EntryDeprecatedRef), + from: from, + name: null, + dependencies: null, + allTransitiveDependencies: null, + debugGetCreateSourceHash: null, + entryId: entryId, + ), + ); + } + + @override + AutoDisposeProviderElement createElement() { + return _EntryDeprecatedProviderElement(this); + } + + @override + bool operator ==(Object other) { + return other is EntryDeprecatedProvider && other.entryId == entryId; + } + + @override + int get hashCode { + var hash = _SystemHash.combine(0, runtimeType.hashCode); + hash = _SystemHash.combine(hash, entryId.hashCode); + + return _SystemHash.finish(hash); + } +} + +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element +mixin EntryDeprecatedRef on AutoDisposeProviderRef { + /// The parameter `entryId` of this provider. + String get entryId; +} + +class _EntryDeprecatedProviderElement + extends AutoDisposeProviderElement + with EntryDeprecatedRef { + _EntryDeprecatedProviderElement(super.provider); + + @override + String get entryId => (origin as EntryDeprecatedProvider).entryId; +} + +String _$isEntryDeprecatedHash() => r'e763f6414bab29d177973400fed8321d8e68b1c7'; /// See also [isEntryDeprecated]. @ProviderFor(isEntryDeprecated) diff --git a/app/lib/models/entry_blueprint.dart b/app/lib/models/entry_blueprint.dart index 69e9078b2a..58a108ff97 100644 --- a/app/lib/models/entry_blueprint.dart +++ b/app/lib/models/entry_blueprint.dart @@ -92,11 +92,12 @@ class EntryBlueprint with _$EntryBlueprint { required String description, required String extension, required ObjectBlueprint dataBlueprint, + @ColorConverter() @Default(Colors.grey) Color color, + @Default(TWIcons.help) String icon, @Default([]) List tags, @Default(null) List? genericConstraints, @Default(null) DataBlueprint? variableDataBlueprint, - @ColorConverter() @Default(Colors.grey) Color color, - @Default(TWIcons.help) String icon, + @Default([]) List modifiers, }) = _EntryBlueprint; factory EntryBlueprint.fromJson(Map json) => @@ -180,6 +181,18 @@ class Modifier with _$Modifier { _$ModifierFromJson(json); } +@Freezed(unionKey: "kind") +class EntryModifier with _$EntryModifier { + const factory EntryModifier() = _EmptyModifier; + + const factory EntryModifier.deprecated({ + @Default("") String reason, + }) = DeprecatedModifier; + + factory EntryModifier.fromJson(Map json) => + _$EntryModifierFromJson(json); +} + const wikiBaseUrl = kDebugMode ? "http://localhost:3000/TypeWriter" : "https://gabber235.github.io/TypeWriter"; diff --git a/app/lib/models/entry_blueprint.freezed.dart b/app/lib/models/entry_blueprint.freezed.dart index 45cd297840..7fb223d827 100644 --- a/app/lib/models/entry_blueprint.freezed.dart +++ b/app/lib/models/entry_blueprint.freezed.dart @@ -25,14 +25,15 @@ mixin _$EntryBlueprint { String get description => throw _privateConstructorUsedError; String get extension => throw _privateConstructorUsedError; ObjectBlueprint get dataBlueprint => throw _privateConstructorUsedError; + @ColorConverter() + Color get color => throw _privateConstructorUsedError; + String get icon => throw _privateConstructorUsedError; List get tags => throw _privateConstructorUsedError; List? get genericConstraints => throw _privateConstructorUsedError; DataBlueprint? get variableDataBlueprint => throw _privateConstructorUsedError; - @ColorConverter() - Color get color => throw _privateConstructorUsedError; - String get icon => throw _privateConstructorUsedError; + List get modifiers => throw _privateConstructorUsedError; /// Serializes this EntryBlueprint to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -56,11 +57,12 @@ abstract class $EntryBlueprintCopyWith<$Res> { String description, String extension, ObjectBlueprint dataBlueprint, + @ColorConverter() Color color, + String icon, List tags, List? genericConstraints, DataBlueprint? variableDataBlueprint, - @ColorConverter() Color color, - String icon}); + List modifiers}); $DataBlueprintCopyWith<$Res>? get variableDataBlueprint; } @@ -85,11 +87,12 @@ class _$EntryBlueprintCopyWithImpl<$Res, $Val extends EntryBlueprint> Object? description = null, Object? extension = null, Object? dataBlueprint = freezed, + Object? color = null, + Object? icon = null, Object? tags = null, Object? genericConstraints = freezed, Object? variableDataBlueprint = freezed, - Object? color = null, - Object? icon = null, + Object? modifiers = null, }) { return _then(_value.copyWith( id: null == id @@ -112,6 +115,14 @@ class _$EntryBlueprintCopyWithImpl<$Res, $Val extends EntryBlueprint> ? _value.dataBlueprint : dataBlueprint // ignore: cast_nullable_to_non_nullable as ObjectBlueprint, + color: null == color + ? _value.color + : color // ignore: cast_nullable_to_non_nullable + as Color, + icon: null == icon + ? _value.icon + : icon // ignore: cast_nullable_to_non_nullable + as String, tags: null == tags ? _value.tags : tags // ignore: cast_nullable_to_non_nullable @@ -124,14 +135,10 @@ class _$EntryBlueprintCopyWithImpl<$Res, $Val extends EntryBlueprint> ? _value.variableDataBlueprint : variableDataBlueprint // ignore: cast_nullable_to_non_nullable as DataBlueprint?, - color: null == color - ? _value.color - : color // ignore: cast_nullable_to_non_nullable - as Color, - icon: null == icon - ? _value.icon - : icon // ignore: cast_nullable_to_non_nullable - as String, + modifiers: null == modifiers + ? _value.modifiers + : modifiers // ignore: cast_nullable_to_non_nullable + as List, ) as $Val); } @@ -164,11 +171,12 @@ abstract class _$$EntryBlueprintImplCopyWith<$Res> String description, String extension, ObjectBlueprint dataBlueprint, + @ColorConverter() Color color, + String icon, List tags, List? genericConstraints, DataBlueprint? variableDataBlueprint, - @ColorConverter() Color color, - String icon}); + List modifiers}); @override $DataBlueprintCopyWith<$Res>? get variableDataBlueprint; @@ -192,11 +200,12 @@ class __$$EntryBlueprintImplCopyWithImpl<$Res> Object? description = null, Object? extension = null, Object? dataBlueprint = freezed, + Object? color = null, + Object? icon = null, Object? tags = null, Object? genericConstraints = freezed, Object? variableDataBlueprint = freezed, - Object? color = null, - Object? icon = null, + Object? modifiers = null, }) { return _then(_$EntryBlueprintImpl( id: null == id @@ -219,6 +228,14 @@ class __$$EntryBlueprintImplCopyWithImpl<$Res> ? _value.dataBlueprint : dataBlueprint // ignore: cast_nullable_to_non_nullable as ObjectBlueprint, + color: null == color + ? _value.color + : color // ignore: cast_nullable_to_non_nullable + as Color, + icon: null == icon + ? _value.icon + : icon // ignore: cast_nullable_to_non_nullable + as String, tags: null == tags ? _value._tags : tags // ignore: cast_nullable_to_non_nullable @@ -231,14 +248,10 @@ class __$$EntryBlueprintImplCopyWithImpl<$Res> ? _value.variableDataBlueprint : variableDataBlueprint // ignore: cast_nullable_to_non_nullable as DataBlueprint?, - color: null == color - ? _value.color - : color // ignore: cast_nullable_to_non_nullable - as Color, - icon: null == icon - ? _value.icon - : icon // ignore: cast_nullable_to_non_nullable - as String, + modifiers: null == modifiers + ? _value._modifiers + : modifiers // ignore: cast_nullable_to_non_nullable + as List, )); } } @@ -254,13 +267,15 @@ class _$EntryBlueprintImpl required this.description, required this.extension, required this.dataBlueprint, + @ColorConverter() this.color = Colors.grey, + this.icon = TWIcons.help, final List tags = const [], final List? genericConstraints = null, this.variableDataBlueprint = null, - @ColorConverter() this.color = Colors.grey, - this.icon = TWIcons.help}) + final List modifiers = const []}) : _tags = tags, - _genericConstraints = genericConstraints; + _genericConstraints = genericConstraints, + _modifiers = modifiers; factory _$EntryBlueprintImpl.fromJson(Map json) => _$$EntryBlueprintImplFromJson(json); @@ -275,6 +290,13 @@ class _$EntryBlueprintImpl final String extension; @override final ObjectBlueprint dataBlueprint; + @override + @JsonKey() + @ColorConverter() + final Color color; + @override + @JsonKey() + final String icon; final List _tags; @override @JsonKey() @@ -299,17 +321,18 @@ class _$EntryBlueprintImpl @override @JsonKey() final DataBlueprint? variableDataBlueprint; + final List _modifiers; @override @JsonKey() - @ColorConverter() - final Color color; - @override - @JsonKey() - final String icon; + List get modifiers { + if (_modifiers is EqualUnmodifiableListView) return _modifiers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_modifiers); + } @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'EntryBlueprint(id: $id, name: $name, description: $description, extension: $extension, dataBlueprint: $dataBlueprint, tags: $tags, genericConstraints: $genericConstraints, variableDataBlueprint: $variableDataBlueprint, color: $color, icon: $icon)'; + return 'EntryBlueprint(id: $id, name: $name, description: $description, extension: $extension, dataBlueprint: $dataBlueprint, color: $color, icon: $icon, tags: $tags, genericConstraints: $genericConstraints, variableDataBlueprint: $variableDataBlueprint, modifiers: $modifiers)'; } @override @@ -322,11 +345,12 @@ class _$EntryBlueprintImpl ..add(DiagnosticsProperty('description', description)) ..add(DiagnosticsProperty('extension', extension)) ..add(DiagnosticsProperty('dataBlueprint', dataBlueprint)) + ..add(DiagnosticsProperty('color', color)) + ..add(DiagnosticsProperty('icon', icon)) ..add(DiagnosticsProperty('tags', tags)) ..add(DiagnosticsProperty('genericConstraints', genericConstraints)) ..add(DiagnosticsProperty('variableDataBlueprint', variableDataBlueprint)) - ..add(DiagnosticsProperty('color', color)) - ..add(DiagnosticsProperty('icon', icon)); + ..add(DiagnosticsProperty('modifiers', modifiers)); } @override @@ -342,13 +366,15 @@ class _$EntryBlueprintImpl other.extension == extension) && const DeepCollectionEquality() .equals(other.dataBlueprint, dataBlueprint) && + (identical(other.color, color) || other.color == color) && + (identical(other.icon, icon) || other.icon == icon) && const DeepCollectionEquality().equals(other._tags, _tags) && const DeepCollectionEquality() .equals(other._genericConstraints, _genericConstraints) && (identical(other.variableDataBlueprint, variableDataBlueprint) || other.variableDataBlueprint == variableDataBlueprint) && - (identical(other.color, color) || other.color == color) && - (identical(other.icon, icon) || other.icon == icon)); + const DeepCollectionEquality() + .equals(other._modifiers, _modifiers)); } @JsonKey(includeFromJson: false, includeToJson: false) @@ -360,11 +386,12 @@ class _$EntryBlueprintImpl description, extension, const DeepCollectionEquality().hash(dataBlueprint), + color, + icon, const DeepCollectionEquality().hash(_tags), const DeepCollectionEquality().hash(_genericConstraints), variableDataBlueprint, - color, - icon); + const DeepCollectionEquality().hash(_modifiers)); /// Create a copy of EntryBlueprint /// with the given fields replaced by the non-null parameter values. @@ -390,11 +417,12 @@ abstract class _EntryBlueprint implements EntryBlueprint { required final String description, required final String extension, required final ObjectBlueprint dataBlueprint, + @ColorConverter() final Color color, + final String icon, final List tags, final List? genericConstraints, final DataBlueprint? variableDataBlueprint, - @ColorConverter() final Color color, - final String icon}) = _$EntryBlueprintImpl; + final List modifiers}) = _$EntryBlueprintImpl; factory _EntryBlueprint.fromJson(Map json) = _$EntryBlueprintImpl.fromJson; @@ -410,16 +438,18 @@ abstract class _EntryBlueprint implements EntryBlueprint { @override ObjectBlueprint get dataBlueprint; @override + @ColorConverter() + Color get color; + @override + String get icon; + @override List get tags; @override List? get genericConstraints; @override DataBlueprint? get variableDataBlueprint; @override - @ColorConverter() - Color get color; - @override - String get icon; + List get modifiers; /// Create a copy of EntryBlueprint /// with the given fields replaced by the non-null parameter values. @@ -3741,3 +3771,383 @@ abstract class _Modifier implements Modifier { _$$ModifierImplCopyWith<_$ModifierImpl> get copyWith => throw _privateConstructorUsedError; } + +EntryModifier _$EntryModifierFromJson(Map json) { + switch (json['kind']) { + case 'default': + return _EmptyModifier.fromJson(json); + case 'deprecated': + return DeprecatedModifier.fromJson(json); + + default: + throw CheckedFromJsonException(json, 'kind', 'EntryModifier', + 'Invalid union type "${json['kind']}"!'); + } +} + +/// @nodoc +mixin _$EntryModifier { + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function(String reason) deprecated, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function(String reason)? deprecated, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function(String reason)? deprecated, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map( + TResult Function(_EmptyModifier value) $default, { + required TResult Function(DeprecatedModifier value) deprecated, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_EmptyModifier value)? $default, { + TResult? Function(DeprecatedModifier value)? deprecated, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap( + TResult Function(_EmptyModifier value)? $default, { + TResult Function(DeprecatedModifier value)? deprecated, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + + /// Serializes this EntryModifier to a JSON map. + Map toJson() => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $EntryModifierCopyWith<$Res> { + factory $EntryModifierCopyWith( + EntryModifier value, $Res Function(EntryModifier) then) = + _$EntryModifierCopyWithImpl<$Res, EntryModifier>; +} + +/// @nodoc +class _$EntryModifierCopyWithImpl<$Res, $Val extends EntryModifier> + implements $EntryModifierCopyWith<$Res> { + _$EntryModifierCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of EntryModifier + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$EmptyModifierImplCopyWith<$Res> { + factory _$$EmptyModifierImplCopyWith( + _$EmptyModifierImpl value, $Res Function(_$EmptyModifierImpl) then) = + __$$EmptyModifierImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$EmptyModifierImplCopyWithImpl<$Res> + extends _$EntryModifierCopyWithImpl<$Res, _$EmptyModifierImpl> + implements _$$EmptyModifierImplCopyWith<$Res> { + __$$EmptyModifierImplCopyWithImpl( + _$EmptyModifierImpl _value, $Res Function(_$EmptyModifierImpl) _then) + : super(_value, _then); + + /// Create a copy of EntryModifier + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +@JsonSerializable() +class _$EmptyModifierImpl + with DiagnosticableTreeMixin + implements _EmptyModifier { + const _$EmptyModifierImpl({final String? $type}) : $type = $type ?? 'default'; + + factory _$EmptyModifierImpl.fromJson(Map json) => + _$$EmptyModifierImplFromJson(json); + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'EntryModifier()'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('type', 'EntryModifier')); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$EmptyModifierImpl); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function(String reason) deprecated, + }) { + return $default(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function(String reason)? deprecated, + }) { + return $default?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function(String reason)? deprecated, + required TResult orElse(), + }) { + if ($default != null) { + return $default(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_EmptyModifier value) $default, { + required TResult Function(DeprecatedModifier value) deprecated, + }) { + return $default(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_EmptyModifier value)? $default, { + TResult? Function(DeprecatedModifier value)? deprecated, + }) { + return $default?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_EmptyModifier value)? $default, { + TResult Function(DeprecatedModifier value)? deprecated, + required TResult orElse(), + }) { + if ($default != null) { + return $default(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$EmptyModifierImplToJson( + this, + ); + } +} + +abstract class _EmptyModifier implements EntryModifier { + const factory _EmptyModifier() = _$EmptyModifierImpl; + + factory _EmptyModifier.fromJson(Map json) = + _$EmptyModifierImpl.fromJson; +} + +/// @nodoc +abstract class _$$DeprecatedModifierImplCopyWith<$Res> { + factory _$$DeprecatedModifierImplCopyWith(_$DeprecatedModifierImpl value, + $Res Function(_$DeprecatedModifierImpl) then) = + __$$DeprecatedModifierImplCopyWithImpl<$Res>; + @useResult + $Res call({String reason}); +} + +/// @nodoc +class __$$DeprecatedModifierImplCopyWithImpl<$Res> + extends _$EntryModifierCopyWithImpl<$Res, _$DeprecatedModifierImpl> + implements _$$DeprecatedModifierImplCopyWith<$Res> { + __$$DeprecatedModifierImplCopyWithImpl(_$DeprecatedModifierImpl _value, + $Res Function(_$DeprecatedModifierImpl) _then) + : super(_value, _then); + + /// Create a copy of EntryModifier + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? reason = null, + }) { + return _then(_$DeprecatedModifierImpl( + reason: null == reason + ? _value.reason + : reason // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DeprecatedModifierImpl + with DiagnosticableTreeMixin + implements DeprecatedModifier { + const _$DeprecatedModifierImpl({this.reason = "", final String? $type}) + : $type = $type ?? 'deprecated'; + + factory _$DeprecatedModifierImpl.fromJson(Map json) => + _$$DeprecatedModifierImplFromJson(json); + + @override + @JsonKey() + final String reason; + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'EntryModifier.deprecated(reason: $reason)'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('type', 'EntryModifier.deprecated')) + ..add(DiagnosticsProperty('reason', reason)); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DeprecatedModifierImpl && + (identical(other.reason, reason) || other.reason == reason)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, reason); + + /// Create a copy of EntryModifier + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DeprecatedModifierImplCopyWith<_$DeprecatedModifierImpl> get copyWith => + __$$DeprecatedModifierImplCopyWithImpl<_$DeprecatedModifierImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function(String reason) deprecated, + }) { + return deprecated(reason); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function(String reason)? deprecated, + }) { + return deprecated?.call(reason); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function(String reason)? deprecated, + required TResult orElse(), + }) { + if (deprecated != null) { + return deprecated(reason); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_EmptyModifier value) $default, { + required TResult Function(DeprecatedModifier value) deprecated, + }) { + return deprecated(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_EmptyModifier value)? $default, { + TResult? Function(DeprecatedModifier value)? deprecated, + }) { + return deprecated?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_EmptyModifier value)? $default, { + TResult Function(DeprecatedModifier value)? deprecated, + required TResult orElse(), + }) { + if (deprecated != null) { + return deprecated(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$DeprecatedModifierImplToJson( + this, + ); + } +} + +abstract class DeprecatedModifier implements EntryModifier { + const factory DeprecatedModifier({final String reason}) = + _$DeprecatedModifierImpl; + + factory DeprecatedModifier.fromJson(Map json) = + _$DeprecatedModifierImpl.fromJson; + + String get reason; + + /// Create a copy of EntryModifier + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DeprecatedModifierImplCopyWith<_$DeprecatedModifierImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/app/lib/models/entry_blueprint.g.dart b/app/lib/models/entry_blueprint.g.dart index df4578f109..d55405c523 100644 --- a/app/lib/models/entry_blueprint.g.dart +++ b/app/lib/models/entry_blueprint.g.dart @@ -14,6 +14,10 @@ _$EntryBlueprintImpl _$$EntryBlueprintImplFromJson(Map json) => extension: json['extension'] as String, dataBlueprint: ObjectBlueprint.fromJson( json['dataBlueprint'] as Map), + color: json['color'] == null + ? Colors.grey + : const ColorConverter().fromJson(json['color'] as String), + icon: json['icon'] as String? ?? TWIcons.help, tags: (json['tags'] as List?)?.map((e) => e as String).toList() ?? const [], @@ -25,10 +29,10 @@ _$EntryBlueprintImpl _$$EntryBlueprintImplFromJson(Map json) => ? null : DataBlueprint.fromJson( json['variableDataBlueprint'] as Map), - color: json['color'] == null - ? Colors.grey - : const ColorConverter().fromJson(json['color'] as String), - icon: json['icon'] as String? ?? TWIcons.help, + modifiers: (json['modifiers'] as List?) + ?.map((e) => EntryModifier.fromJson(e as Map)) + .toList() ?? + const [], ); Map _$$EntryBlueprintImplToJson( @@ -39,12 +43,13 @@ Map _$$EntryBlueprintImplToJson( 'description': instance.description, 'extension': instance.extension, 'dataBlueprint': instance.dataBlueprint.toJson(), + 'color': const ColorConverter().toJson(instance.color), + 'icon': instance.icon, 'tags': instance.tags, 'genericConstraints': instance.genericConstraints?.map((e) => e.toJson()).toList(), 'variableDataBlueprint': instance.variableDataBlueprint?.toJson(), - 'color': const ColorConverter().toJson(instance.color), - 'icon': instance.icon, + 'modifiers': instance.modifiers.map((e) => e.toJson()).toList(), }; _$DataBlueprintTypeImpl _$$DataBlueprintTypeImplFromJson( @@ -237,6 +242,30 @@ Map _$$ModifierImplToJson(_$ModifierImpl instance) => 'data': instance.data, }; +_$EmptyModifierImpl _$$EmptyModifierImplFromJson(Map json) => + _$EmptyModifierImpl( + $type: json['kind'] as String?, + ); + +Map _$$EmptyModifierImplToJson(_$EmptyModifierImpl instance) => + { + 'kind': instance.$type, + }; + +_$DeprecatedModifierImpl _$$DeprecatedModifierImplFromJson( + Map json) => + _$DeprecatedModifierImpl( + reason: json['reason'] as String? ?? "", + $type: json['kind'] as String?, + ); + +Map _$$DeprecatedModifierImplToJson( + _$DeprecatedModifierImpl instance) => + { + 'reason': instance.reason, + 'kind': instance.$type, + }; + // ************************************************************************** // RiverpodGenerator // ************************************************************************** diff --git a/app/lib/models/extension.dart b/app/lib/models/extension.dart index 9499631822..f512af7fdc 100644 --- a/app/lib/models/extension.dart +++ b/app/lib/models/extension.dart @@ -1,5 +1,6 @@ import "package:flutter/foundation.dart"; import "package:freezed_annotation/freezed_annotation.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:riverpod_annotation/riverpod_annotation.dart"; import "package:typewriter/models/book.dart"; import "package:typewriter/models/entry_blueprint.dart"; @@ -9,8 +10,7 @@ part "extension.g.dart"; /// A generated provider to fetch and cache a list of [Extension]s. @riverpod -List extensions(ExtensionsRef ref) => - ref.watch(bookProvider).extensions; +List extensions(Ref ref) => ref.watch(bookProvider).extensions; /// A data model that represents an extension. @freezed diff --git a/app/lib/models/extension.g.dart b/app/lib/models/extension.g.dart index 7eb4a532d2..3b9187f26d 100644 --- a/app/lib/models/extension.g.dart +++ b/app/lib/models/extension.g.dart @@ -41,7 +41,7 @@ Map _$$ExtensionInfoImplToJson(_$ExtensionInfoImpl instance) => // RiverpodGenerator // ************************************************************************** -String _$extensionsHash() => r'c5ab97411f68e5201eaf3154a8c578929e519906'; +String _$extensionsHash() => r'10f9edbc062d3761b5fdbeb067a30725925444ba'; /// A generated provider to fetch and cache a list of [Extension]s. /// diff --git a/app/lib/models/page.dart b/app/lib/models/page.dart index 7a4b88f201..679a955dfc 100644 --- a/app/lib/models/page.dart +++ b/app/lib/models/page.dart @@ -24,37 +24,37 @@ List pages(Ref ref) { } @riverpod -Page? page(PageRef ref, String pageId) { +Page? page(Ref ref, String pageId) { return ref.watch(pagesProvider).firstWhereOrNull((page) => page.id == pageId); } @riverpod -String? pageName(PageNameRef ref, String pageId) { +String? pageName(Ref ref, String pageId) { return ref.watch(pageProvider(pageId))?.pageName; } @riverpod -bool pageExists(PageExistsRef ref, String pageId) { +bool pageExists(Ref ref, String pageId) { return ref.watch(pageProvider(pageId)) != null; } @riverpod -PageType pageType(PageTypeRef ref, String pageId) { +PageType pageType(Ref ref, String pageId) { return ref.watch(pageProvider(pageId))?.type ?? PageType.sequence; } @riverpod -String pageChapter(PageChapterRef ref, String pageId) { +String pageChapter(Ref ref, String pageId) { return ref.watch(pageProvider(pageId))?.chapter ?? ""; } @riverpod -int pagePriority(PagePriorityRef ref, String pageId) { +int pagePriority(Ref ref, String pageId) { return ref.watch(pageProvider(pageId))?.priority ?? 0; } @riverpod -String? entryPageId(EntryPageIdRef ref, String entryId) { +String? entryPageId(Ref ref, String entryId) { return ref .watch(pagesProvider) .firstWhereOrNull( @@ -64,14 +64,14 @@ String? entryPageId(EntryPageIdRef ref, String entryId) { } @riverpod -Page? entryPage(EntryPageRef ref, String entryId) { +Page? entryPage(Ref ref, String entryId) { return ref.watch(pagesProvider).firstWhereOrNull( (page) => page.entries.any((entry) => entry.id == entryId), ); } @riverpod -Entry? entry(EntryRef ref, String pageId, String entryId) { +Entry? entry(Ref ref, String pageId, String entryId) { return ref .watch(pageProvider(pageId)) ?.entries @@ -79,7 +79,7 @@ Entry? entry(EntryRef ref, String pageId, String entryId) { } @riverpod -Entry? globalEntry(GlobalEntryRef ref, String entryId) { +Entry? globalEntry(Ref ref, String entryId) { final pages = ref.watch(pagesProvider); for (final page in pages) { final entry = page.entries.firstWhereOrNull((entry) => entry.id == entryId); @@ -92,7 +92,7 @@ Entry? globalEntry(GlobalEntryRef ref, String entryId) { @riverpod MapEntry? globalEntryWithPage( - GlobalEntryWithPageRef ref, + Ref ref, String entryId, ) { final pageId = ref.watch(entryPageIdProvider(entryId)); @@ -107,7 +107,7 @@ MapEntry? globalEntryWithPage( } @riverpod -bool entryExists(EntryExistsRef ref, String entryId) { +bool entryExists(Ref ref, String entryId) { return ref.watch(entryPageIdProvider(entryId)) != null; } diff --git a/app/lib/models/page.g.dart b/app/lib/models/page.g.dart index 50bedd94bc..08cf8036f3 100644 --- a/app/lib/models/page.g.dart +++ b/app/lib/models/page.g.dart @@ -55,7 +55,7 @@ final pagesProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef PagesRef = AutoDisposeProviderRef>; -String _$pageHash() => r'884d7b74470acd1d1cd7aefeb91f51364a14ba89'; +String _$pageHash() => r'0a64fb393bca5b9568593eff3cb7875f420079c4'; /// Copied from Dart SDK class _SystemHash { @@ -203,7 +203,7 @@ class _PageProviderElement extends AutoDisposeProviderElement String get pageId => (origin as PageProvider).pageId; } -String _$pageNameHash() => r'c1089bcbebabddfc3bb11a9ba52b4019a761cd11'; +String _$pageNameHash() => r'83de166c1918556851736ebfc4ad2b7f0a08de38'; /// See also [pageName]. @ProviderFor(pageName) @@ -332,7 +332,7 @@ class _PageNameProviderElement extends AutoDisposeProviderElement String get pageId => (origin as PageNameProvider).pageId; } -String _$pageExistsHash() => r'68e3ea46a1e212bb9bc01ac653a749e9668d47f3'; +String _$pageExistsHash() => r'f4cfe7ab230e2aae357a3cbf98532412b4910190'; /// See also [pageExists]. @ProviderFor(pageExists) @@ -462,7 +462,7 @@ class _PageExistsProviderElement extends AutoDisposeProviderElement String get pageId => (origin as PageExistsProvider).pageId; } -String _$pageTypeHash() => r'e22516e95c00d6723256e425e31624dc3beccddb'; +String _$pageTypeHash() => r'64a1e3a7c12314dd84c1657080b2407f0ce679d9'; /// See also [pageType]. @ProviderFor(pageType) @@ -591,7 +591,7 @@ class _PageTypeProviderElement extends AutoDisposeProviderElement String get pageId => (origin as PageTypeProvider).pageId; } -String _$pageChapterHash() => r'c8725780b13e27c6bfb7ade62625aabb4d7ca392'; +String _$pageChapterHash() => r'54c694d5e588ee7c2fe4fb0e7a897effe8611d6e'; /// See also [pageChapter]. @ProviderFor(pageChapter) @@ -721,7 +721,7 @@ class _PageChapterProviderElement extends AutoDisposeProviderElement String get pageId => (origin as PageChapterProvider).pageId; } -String _$pagePriorityHash() => r'340f23a4c9b80bbd159ea066d79044424a8e4692'; +String _$pagePriorityHash() => r'faab7535ff7dd5740fae3e8be7a21f20e2850a05'; /// See also [pagePriority]. @ProviderFor(pagePriority) @@ -851,7 +851,7 @@ class _PagePriorityProviderElement extends AutoDisposeProviderElement String get pageId => (origin as PagePriorityProvider).pageId; } -String _$entryPageIdHash() => r'a317d09f9de338ebefec45be649af4dc1c60a22d'; +String _$entryPageIdHash() => r'77d5208e639015cb3924cd0f7c418c768960bbfc'; /// See also [entryPageId]. @ProviderFor(entryPageId) @@ -981,7 +981,7 @@ class _EntryPageIdProviderElement extends AutoDisposeProviderElement String get entryId => (origin as EntryPageIdProvider).entryId; } -String _$entryPageHash() => r'00d12a29c4a1bfdec76651cba6577d582e65e20a'; +String _$entryPageHash() => r'c211aaca338fc322b5ed5e507ed4fb01a45cf006'; /// See also [entryPage]. @ProviderFor(entryPage) @@ -1110,7 +1110,7 @@ class _EntryPageProviderElement extends AutoDisposeProviderElement String get entryId => (origin as EntryPageProvider).entryId; } -String _$entryHash() => r'f1e00a6ad6ab8e50c1e2178680c8004c98dea055'; +String _$entryHash() => r'4f7812f8b229def777e69725f6b6ff71791947a7'; /// See also [entry]. @ProviderFor(entry) @@ -1256,7 +1256,7 @@ class _EntryProviderElement extends AutoDisposeProviderElement String get entryId => (origin as EntryProvider).entryId; } -String _$globalEntryHash() => r'f304c143cc53b98eeccb7696c4c1152464820b93'; +String _$globalEntryHash() => r'9ce38058f363853e038e26d4b77c90132c321b2c'; /// See also [globalEntry]. @ProviderFor(globalEntry) @@ -1387,7 +1387,7 @@ class _GlobalEntryProviderElement extends AutoDisposeProviderElement } String _$globalEntryWithPageHash() => - r'003dec3f932daec4549b62ae8bb744dc256310ec'; + r'e9d3d8e0b4cda57d378bfc322c126ee1e9562905'; /// See also [globalEntryWithPage]. @ProviderFor(globalEntryWithPage) @@ -1520,7 +1520,7 @@ class _GlobalEntryWithPageProviderElement String get entryId => (origin as GlobalEntryWithPageProvider).entryId; } -String _$entryExistsHash() => r'5280290c9246fb7003da2717fc9a1639c952a286'; +String _$entryExistsHash() => r'fe9eaeb7c200721137ea1800de89e040ac0b6111'; /// See also [entryExists]. @ProviderFor(entryExists) diff --git a/app/lib/models/potion_effects.dart b/app/lib/models/potion_effects.dart index fec488f5ca..db01eef791 100644 --- a/app/lib/models/potion_effects.dart +++ b/app/lib/models/potion_effects.dart @@ -2,6 +2,7 @@ import "dart:convert"; import "package:flutter/material.dart"; import "package:flutter_animate/flutter_animate.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:http/http.dart" as http; import "package:riverpod_annotation/riverpod_annotation.dart"; import "package:typewriter/main.dart"; @@ -11,7 +12,7 @@ part "potion_effects.g.dart"; const _minecraftRegistriesUrl = "$mcmetaUrl/summary/registries/data.min.json"; @riverpod -Future> potionEffects(PotionEffectsRef ref) async { +Future> potionEffects(Ref ref) async { final response = await http.get(Uri.parse(_minecraftRegistriesUrl)).timeout(5.seconds); if (response.statusCode != 200) { diff --git a/app/lib/models/potion_effects.g.dart b/app/lib/models/potion_effects.g.dart index c162a6cc86..518c7f5e87 100644 --- a/app/lib/models/potion_effects.g.dart +++ b/app/lib/models/potion_effects.g.dart @@ -6,7 +6,7 @@ part of 'potion_effects.dart'; // RiverpodGenerator // ************************************************************************** -String _$potionEffectsHash() => r'7d4bca2a7f53566cc2fa18c241b7e0e8080da1ee'; +String _$potionEffectsHash() => r'cff5a428c3adf9861c2cc4c1929b697b918cf22f'; /// See also [potionEffects]. @ProviderFor(potionEffects) diff --git a/app/lib/models/segment.dart b/app/lib/models/segment.dart index 1e5edc3cc0..86655f8e1c 100644 --- a/app/lib/models/segment.dart +++ b/app/lib/models/segment.dart @@ -1,6 +1,7 @@ import "package:collection_ext/all.dart"; import "package:flutter/material.dart"; import "package:freezed_annotation/freezed_annotation.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:riverpod_annotation/riverpod_annotation.dart"; import "package:typewriter/models/writers.dart"; import "package:typewriter/utils/extensions.dart"; @@ -11,7 +12,7 @@ part "segment.freezed.dart"; @riverpod List segmentWriters( - SegmentWritersRef ref, + Ref ref, String entryId, String segmentId, ) { diff --git a/app/lib/models/segment.g.dart b/app/lib/models/segment.g.dart index b46d18a0b1..d7f58b12dd 100644 --- a/app/lib/models/segment.g.dart +++ b/app/lib/models/segment.g.dart @@ -6,7 +6,7 @@ part of 'segment.dart'; // RiverpodGenerator // ************************************************************************** -String _$segmentWritersHash() => r'011eacd554b34d97ed234e8d2a30d527854c1a20'; +String _$segmentWritersHash() => r'316bcd141d3ba90d3ffc8ea857dda7eb92c68b57'; /// Copied from Dart SDK class _SystemHash { diff --git a/app/lib/models/sounds.dart b/app/lib/models/sounds.dart index e93bdb6938..872b9d5704 100644 --- a/app/lib/models/sounds.dart +++ b/app/lib/models/sounds.dart @@ -2,6 +2,7 @@ import "dart:convert"; import "dart:math"; import "package:freezed_annotation/freezed_annotation.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:http/http.dart" as http; import "package:riverpod_annotation/riverpod_annotation.dart"; import "package:typewriter/main.dart"; @@ -51,7 +52,7 @@ const _minecraftSoundsUrl = "$mcmetaUrl/summary/sounds/data.min.json"; @Riverpod(keepAlive: true) Future>> minecraftSounds( - MinecraftSoundsRef ref, + Ref ref, ) async { final response = await http.get(Uri.parse(_minecraftSoundsUrl)); if (response.statusCode != 200) { @@ -61,7 +62,7 @@ Future>> minecraftSounds( } @riverpod -Future minecraftSound(MinecraftSoundRef ref, String id) async { +Future minecraftSound(Ref ref, String id) async { final strippedId = id.replacePrefix("minecraft:", ""); final sounds = await ref.watch(minecraftSoundsProvider.future); if (!sounds.containsKey(strippedId)) return null; diff --git a/app/lib/models/sounds.g.dart b/app/lib/models/sounds.g.dart index 396ab62a79..f8031c9bf0 100644 --- a/app/lib/models/sounds.g.dart +++ b/app/lib/models/sounds.g.dart @@ -24,7 +24,7 @@ Map _$$SoundDataImplToJson(_$SoundDataImpl instance) => // RiverpodGenerator // ************************************************************************** -String _$minecraftSoundsHash() => r'057ac7e0ea33c9ed26f63e57a67091721811fd50'; +String _$minecraftSoundsHash() => r'8b076052ce4f7820879dbc7a58a7cd2c88e18daa'; /// See also [minecraftSounds]. @ProviderFor(minecraftSounds) @@ -42,7 +42,7 @@ final minecraftSoundsProvider = @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef MinecraftSoundsRef = FutureProviderRef>>; -String _$minecraftSoundHash() => r'360718281dd98a11b4669309eee983425b822717'; +String _$minecraftSoundHash() => r'd72a6c9ec2a8ff432008b0d42e1367b248e64b87'; /// Copied from Dart SDK class _SystemHash { diff --git a/app/lib/models/writers.dart b/app/lib/models/writers.dart index 6cd35e3afe..2c7267486a 100644 --- a/app/lib/models/writers.dart +++ b/app/lib/models/writers.dart @@ -18,7 +18,7 @@ part "writers.g.dart"; /// [path] the given path of the field. @riverpod List fieldWriters( - FieldWritersRef ref, + Ref ref, String path, { bool exact = false, }) { diff --git a/app/lib/models/writers.g.dart b/app/lib/models/writers.g.dart index 817bf36d56..65d2ccbd46 100644 --- a/app/lib/models/writers.g.dart +++ b/app/lib/models/writers.g.dart @@ -27,7 +27,7 @@ Map _$$WriterImplToJson(_$WriterImpl instance) => // RiverpodGenerator // ************************************************************************** -String _$fieldWritersHash() => r'1dd7121d271352fa9727b6bc811f6776c06c63d4'; +String _$fieldWritersHash() => r'058e25b8c67c7ba7887c006d4866378c856d25a5'; /// Copied from Dart SDK class _SystemHash { diff --git a/app/lib/pages/pages_list.dart b/app/lib/pages/pages_list.dart index f6bba2988a..7b57000187 100644 --- a/app/lib/pages/pages_list.dart +++ b/app/lib/pages/pages_list.dart @@ -46,7 +46,7 @@ class _PageData with _$PageData { } @riverpod -List<_PageData> _pagesData(_PagesDataRef ref) { +List<_PageData> _pagesData(Ref ref) { return ref .watch(bookProvider) .pages @@ -62,7 +62,7 @@ List<_PageData> _pagesData(_PagesDataRef ref) { } @riverpod -RootTreeNode<_PageData> _pagesTree(_PagesTreeRef ref) { +RootTreeNode<_PageData> _pagesTree(Ref ref) { return createTreeNode( ref.watch(_pagesDataProvider), (e) => e.chapter, @@ -70,7 +70,7 @@ RootTreeNode<_PageData> _pagesTree(_PagesTreeRef ref) { } @riverpod -List _pageNames(_PageNamesRef ref) { +List _pageNames(Ref ref) { return ref.watch( _pagesDataProvider .select((pages) => pages.map((page) => page.name).toList()), @@ -366,7 +366,7 @@ class _TreeCategory extends HookConsumerWidget { } @riverpod -List _writers(_WritersRef ref, String pageId) { +List _writers(Ref ref, String pageId) { return ref .watch(writersProvider) .where((writer) => writer.pageId.hasValue && writer.pageId == pageId) diff --git a/app/lib/pages/pages_list.g.dart b/app/lib/pages/pages_list.g.dart index d9b2d4b18a..fc8b219236 100644 --- a/app/lib/pages/pages_list.g.dart +++ b/app/lib/pages/pages_list.g.dart @@ -6,7 +6,7 @@ part of 'pages_list.dart'; // RiverpodGenerator // ************************************************************************** -String _$pagesDataHash() => r'dde2241455047364635cf0985d51de217c282fc0'; +String _$pagesDataHash() => r'fc39d71b4905b7fe4412a26ec01ac2e04a84c0b7'; /// See also [_pagesData]. @ProviderFor(_pagesData) @@ -22,7 +22,7 @@ final _pagesDataProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _PagesDataRef = AutoDisposeProviderRef>; -String _$pagesTreeHash() => r'019eebde840b5af25aae49b4b3af4db61c5ac7a1'; +String _$pagesTreeHash() => r'5d7f6a96ed485617ef185a17a3dbbc9d2a9e508e'; /// See also [_pagesTree]. @ProviderFor(_pagesTree) @@ -39,7 +39,7 @@ final _pagesTreeProvider = @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _PagesTreeRef = AutoDisposeProviderRef>; -String _$pageNamesHash() => r'd834681c3a622b64fd2562eb17db3434db172946'; +String _$pageNamesHash() => r'ba8e2fb564a7aa92ae49a419151c8f4f39bcf0f4'; /// See also [_pageNames]. @ProviderFor(_pageNames) @@ -55,7 +55,7 @@ final _pageNamesProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _PageNamesRef = AutoDisposeProviderRef>; -String _$writersHash() => r'49be74d2cb1d297d1af054c85976d3f6c4251713'; +String _$writersHash() => r'67ebaf51392a3c4ff731ca624a60a92b56c9c253'; /// Copied from Dart SDK class _SystemHash { diff --git a/app/lib/utils/audio_player.dart b/app/lib/utils/audio_player.dart index a1ec4b106e..01e76e9b0f 100644 --- a/app/lib/utils/audio_player.dart +++ b/app/lib/utils/audio_player.dart @@ -1,9 +1,10 @@ import "package:audioplayers/audioplayers.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:riverpod_annotation/riverpod_annotation.dart"; part "audio_player.g.dart"; @riverpod -AudioPlayer audioPlayer(AudioPlayerRef ref) { +AudioPlayer audioPlayer(Ref ref) { return AudioPlayer(); } diff --git a/app/lib/utils/audio_player.g.dart b/app/lib/utils/audio_player.g.dart index d6e0ec60be..3fd6e6686f 100644 --- a/app/lib/utils/audio_player.g.dart +++ b/app/lib/utils/audio_player.g.dart @@ -6,7 +6,7 @@ part of 'audio_player.dart'; // RiverpodGenerator // ************************************************************************** -String _$audioPlayerHash() => r'0f9f941057440935279fb5ed67e9d88ff0d6549a'; +String _$audioPlayerHash() => r'ea892a42ea88b5901219a87b65cb53035bf65070'; /// See also [audioPlayer]. @ProviderFor(audioPlayer) diff --git a/app/lib/utils/debouncer.dart b/app/lib/utils/debouncer.dart index 4fc856646b..9e7fc983d9 100644 --- a/app/lib/utils/debouncer.dart +++ b/app/lib/utils/debouncer.dart @@ -8,7 +8,7 @@ typedef FutureOrVoidValueCallback = FutureOr Function(T); /// after a certain amount of time has passed without the action being triggered /// again. The debouncer allows you to "group" multiple triggers into one action. /// -/// The is the type of the value that is passed to the callback. +/// The \ is the type of the value that is passed to the callback. class Debouncer { Debouncer({required this.duration, required this.callback}); diff --git a/app/lib/widgets/components/app/cinematic_view.dart b/app/lib/widgets/components/app/cinematic_view.dart index a19abfb6b7..6022cb5f52 100644 --- a/app/lib/widgets/components/app/cinematic_view.dart +++ b/app/lib/widgets/components/app/cinematic_view.dart @@ -88,7 +88,7 @@ void deleteSegmentConfirmation( } @riverpod -Segment? inspectingSegment(InspectingSegmentRef ref) { +Segment? inspectingSegment(Ref ref) { final segmentId = ref.watch(inspectingSegmentIdProvider); if (segmentId == null) return null; @@ -159,7 +159,7 @@ String? _addSegment( } @riverpod -List _allSegments(_AllSegmentsRef ref, String entryId) { +List _allSegments(Ref ref, String entryId) { final paths = ref.watch(_segmentPathsProvider(entryId)); return paths.keys .map((path) => ref.watch(_segmentsProvider(entryId, path))) @@ -169,7 +169,7 @@ List _allSegments(_AllSegmentsRef ref, String entryId) { } @riverpod -List _cinematicEntryIds(_CinematicEntryIdsRef ref) { +List _cinematicEntryIds(Ref ref) { final page = ref.watch(currentPageProvider); if (page == null) return []; @@ -237,14 +237,14 @@ void _duplicateSelectedSegment(PassingRef ref) { } @riverpod -int _endingFrame(_EndingFrameRef ref, String entryId) { +int _endingFrame(Ref ref, String entryId) { final segments = ref.watch(_allSegmentsProvider(entryId)); return segments.map((segment) => segment.endFrame).maxOrNull ?? 0; } @riverpod List _entryContextActions( - _EntryContextActionsRef ref, + Ref ref, String entryId, ) { final paths = ref.watch(_segmentPathsProvider(entryId)); @@ -330,14 +330,14 @@ List _entryContextActions( } @riverpod -double _frameEndOffset(_FrameEndOffsetRef ref, int frame) { +double _frameEndOffset(Ref ref, int frame) { final trackSize = ref.watch(_trackSizeProvider); final frameSpacing = ref.watch(_frameSpacingProvider); return trackSize - frame * frameSpacing; } @riverpod -double _frameSpacing(_FrameSpacingRef ref) { +double _frameSpacing(Ref ref) { final trackState = ref.watch(_trackStateProvider); final totalFrames = trackState.totalFrames; final width = trackState.width - 16; @@ -351,13 +351,13 @@ double _frameSpacing(_FrameSpacingRef ref) { } @riverpod -double _frameStartOffset(_FrameStartOffsetRef ref, int frame) { +double _frameStartOffset(Ref ref, int frame) { final frameSpacing = ref.watch(_frameSpacingProvider); return frame * frameSpacing; } @riverpod -List _ignoreEntryFields(_IgnoreEntryFieldsRef ref) { +List _ignoreEntryFields(Ref ref) { final entryId = ref.watch(inspectingEntryIdProvider); if (entryId == null) return []; @@ -382,7 +382,7 @@ Segment? _includesSegment( // @riverpod -String _longestEntryName(_LongestEntryNameRef ref) { +String _longestEntryName(Ref ref) { final entryIds = ref.watch(_cinematicEntryIdsProvider); final names = entryIds .map((entryId) => ref.watch(entryNameProvider(entryId))) @@ -395,7 +395,7 @@ String _longestEntryName(_LongestEntryNameRef ref) { } @riverpod -ObjectBlueprint? _segmentFields(_SegmentFieldsRef ref) { +ObjectBlueprint? _segmentFields(Ref ref) { final blueprint = ref.watch( inspectingEntryDefinitionProvider .select((definition) => definition?.blueprint), @@ -410,7 +410,7 @@ ObjectBlueprint? _segmentFields(_SegmentFieldsRef ref) { // @riverpod -Map _segmentPaths(_SegmentPathsRef ref, String entryId) { +Map _segmentPaths(Ref ref, String entryId) { final blueprintId = ref.watch(entryBlueprintIdProvider(entryId)); if (blueprintId == null) return {}; final blueprint = ref.watch(entryBlueprintProvider(blueprintId)); @@ -420,7 +420,7 @@ Map _segmentPaths(_SegmentPathsRef ref, String entryId) { } @riverpod -List _segments(_SegmentsRef ref, String entryId, String path) { +List _segments(Ref ref, String entryId, String path) { final paths = ref.watch(_segmentPathsProvider(entryId)); final modifier = paths.findModifier(path); if (modifier == null) return []; @@ -464,7 +464,7 @@ List _segments(_SegmentsRef ref, String entryId, String path) { } @riverpod -bool _showThumbs(_ShowThumbsRef ref, int startFrame, int endFrame) { +bool _showThumbs(Ref ref, int startFrame, int endFrame) { if (startFrame == endFrame) return false; final startOffset = ref.watch(_frameStartOffsetProvider(startFrame)); // We want to use the start offset provider here as we want the offset from the start of the track to the end of the frame. @@ -474,14 +474,14 @@ bool _showThumbs(_ShowThumbsRef ref, int startFrame, int endFrame) { } @riverpod -double _sliderEndOffset(_SliderEndOffsetRef ref) { +double _sliderEndOffset(Ref ref) { final end = ref.watch(_trackStateProvider.select((state) => state.end)); final width = ref.watch(_trackStateProvider.select((state) => state.width)); return (1 - end) * width; } @riverpod -double _sliderStartOffset(_SliderStartOffsetRef ref) { +double _sliderStartOffset(Ref ref) { final start = ref.watch(_trackStateProvider.select((state) => state.start)); final width = ref.watch(_trackStateProvider.select((state) => state.width)); return start * width; @@ -489,7 +489,7 @@ double _sliderStartOffset(_SliderStartOffsetRef ref) { @riverpod List _timeFractionFrames( - _TimeFractionFramesRef ref, { + Ref ref, { double fractionModifier = 1.0, }) { final startFrame = @@ -504,7 +504,7 @@ List _timeFractionFrames( } @riverpod -int _timeFractions(_TimeFractionsRef ref) { +int _timeFractions(Ref ref) { final duration = ref.watch(_trackStateProvider.select((state) => state.duration)); final width = ref.watch(_trackStateProvider.select((state) => state.width)); @@ -516,7 +516,7 @@ int _timeFractions(_TimeFractionsRef ref) { @riverpod double _timePointOffset( - _TimePointOffsetRef ref, + Ref ref, int frame, double widgetWidth, ) { @@ -530,7 +530,7 @@ double _timePointOffset( } @riverpod -int _totalSequenceFrames(_TotalSequenceFramesRef ref) { +int _totalSequenceFrames(Ref ref) { final entryIds = ref.watch(_cinematicEntryIdsProvider); final frames = entryIds .map((entryId) => ref.watch(_endingFrameProvider(entryId))) @@ -541,7 +541,7 @@ int _totalSequenceFrames(_TotalSequenceFramesRef ref) { @riverpod double _trackBackgroundFractionModifier( - _TrackBackgroundFractionModifierRef ref, + Ref ref, ) { final fractions = ref.watch(_timeFractionsProvider); if (fractions == 1) return 1.0; @@ -550,7 +550,7 @@ double _trackBackgroundFractionModifier( } @riverpod -List<_FrameLine> _trackBackgroundLines(_TrackBackgroundLinesRef ref) { +List<_FrameLine> _trackBackgroundLines(Ref ref) { final fractions = ref.watch(_timeFractionsProvider); final fractionModifier = ref.watch(_trackBackgroundFractionModifierProvider); final fractionFrames = ref @@ -573,7 +573,7 @@ List<_FrameLine> _trackBackgroundLines(_TrackBackgroundLinesRef ref) { } @riverpod -double _trackOffset(_TrackOffsetRef ref) { +double _trackOffset(Ref ref) { final trackState = ref.watch(_trackStateProvider); final totalFrames = trackState.totalFrames; @@ -585,7 +585,7 @@ double _trackOffset(_TrackOffsetRef ref) { } @riverpod -double _trackSize(_TrackSizeRef ref) { +double _trackSize(Ref ref) { final totalFrames = ref.watch(_trackStateProvider.select((state) => state.totalFrames)); final spacing = ref.watch(_frameSpacingProvider); @@ -2032,8 +2032,7 @@ class _TrackStateProvider extends StateNotifier<_TrackState> { ); } static const _minWidth = 40; - final AutoDisposeStateNotifierProviderRef<_TrackStateProvider, _TrackState> - ref; + final Ref ref; double calculateDelta(double delta) => delta / state.width; void changeTotalFrames(int totalFrames) { diff --git a/app/lib/widgets/components/app/cinematic_view.g.dart b/app/lib/widgets/components/app/cinematic_view.g.dart index 19ae6c701f..d1f8154de8 100644 --- a/app/lib/widgets/components/app/cinematic_view.g.dart +++ b/app/lib/widgets/components/app/cinematic_view.g.dart @@ -6,7 +6,7 @@ part of 'cinematic_view.dart'; // RiverpodGenerator // ************************************************************************** -String _$inspectingSegmentHash() => r'd7155fa87adad4c7e894d76ec98a91c9096f7632'; +String _$inspectingSegmentHash() => r'ed4c81bad81f7e3c3bde22dba48ded426d04b2b7'; /// See also [inspectingSegment]. @ProviderFor(inspectingSegment) @@ -23,7 +23,7 @@ final inspectingSegmentProvider = AutoDisposeProvider.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef InspectingSegmentRef = AutoDisposeProviderRef; -String _$allSegmentsHash() => r'cd0016ec442c5c46570cedbdde8893c1a52890df'; +String _$allSegmentsHash() => r'c62776e776362e7b097ed238098d3778aa7e06fb'; /// Copied from Dart SDK class _SystemHash { @@ -174,7 +174,7 @@ class _AllSegmentsProviderElement String get entryId => (origin as _AllSegmentsProvider).entryId; } -String _$cinematicEntryIdsHash() => r'd605052793e8cd783fa8fbb6ed8ea754ccc60023'; +String _$cinematicEntryIdsHash() => r'd535a2e4dbb60f81ae1cea64b14115494b4422d9'; /// See also [_cinematicEntryIds]. @ProviderFor(_cinematicEntryIds) @@ -191,7 +191,7 @@ final _cinematicEntryIdsProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _CinematicEntryIdsRef = AutoDisposeProviderRef>; -String _$endingFrameHash() => r'b1ee54645a8ea133a3e35488b84aeb79b9701544'; +String _$endingFrameHash() => r'32fe11589339925d2765108f9b9d2c7e32b4ff39'; /// See also [_endingFrame]. @ProviderFor(_endingFrame) @@ -322,7 +322,7 @@ class _EndingFrameProviderElement extends AutoDisposeProviderElement } String _$entryContextActionsHash() => - r'06b97aad5ea69b9a379f88525625aa8c7065d4c3'; + r'5c4353ae741b4bafd2046b9a801e77324fa8977f'; /// See also [_entryContextActions]. @ProviderFor(_entryContextActions) @@ -454,7 +454,7 @@ class _EntryContextActionsProviderElement String get entryId => (origin as _EntryContextActionsProvider).entryId; } -String _$frameEndOffsetHash() => r'23292b810d25146945a92761725780a6c01c5616'; +String _$frameEndOffsetHash() => r'7537d90b87f974f1f7c9af4f248c46d19e33af1c'; /// See also [_frameEndOffset]. @ProviderFor(_frameEndOffset) @@ -584,7 +584,7 @@ class _FrameEndOffsetProviderElement extends AutoDisposeProviderElement int get frame => (origin as _FrameEndOffsetProvider).frame; } -String _$frameSpacingHash() => r'b6efbe3e7da758078921b18a6b91cdd506f86895'; +String _$frameSpacingHash() => r'218185e0394e01b13c8bf37d402c638f4810d890'; /// See also [_frameSpacing]. @ProviderFor(_frameSpacing) @@ -600,7 +600,7 @@ final _frameSpacingProvider = AutoDisposeProvider.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _FrameSpacingRef = AutoDisposeProviderRef; -String _$frameStartOffsetHash() => r'13381822c602dddec85110a9b1c3855a47c07172'; +String _$frameStartOffsetHash() => r'66a08dadb3741c0836d98b6968601b1079b91cb6'; /// See also [_frameStartOffset]. @ProviderFor(_frameStartOffset) @@ -730,7 +730,7 @@ class _FrameStartOffsetProviderElement int get frame => (origin as _FrameStartOffsetProvider).frame; } -String _$ignoreEntryFieldsHash() => r'602c6ed49c2d349912b9a3d448e72be350e9d4aa'; +String _$ignoreEntryFieldsHash() => r'3f09b6a0644048aebb3a520525b47943c085cb84'; /// See also [_ignoreEntryFields]. @ProviderFor(_ignoreEntryFields) @@ -747,7 +747,7 @@ final _ignoreEntryFieldsProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _IgnoreEntryFieldsRef = AutoDisposeProviderRef>; -String _$longestEntryNameHash() => r'e28faa48892dbb64da18b39177390e09c73dc820'; +String _$longestEntryNameHash() => r'efa686f5099bd11a9e5cc5a52f883932f58d471d'; /// See also [_longestEntryName]. @ProviderFor(_longestEntryName) @@ -764,7 +764,7 @@ final _longestEntryNameProvider = AutoDisposeProvider.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _LongestEntryNameRef = AutoDisposeProviderRef; -String _$segmentFieldsHash() => r'bf02df2288101b0055b4c2376e4f4336b36c8f37'; +String _$segmentFieldsHash() => r'09d6b3e1c5428165e80cd122e634e33cdf031099'; /// See also [_segmentFields]. @ProviderFor(_segmentFields) @@ -781,7 +781,7 @@ final _segmentFieldsProvider = AutoDisposeProvider.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _SegmentFieldsRef = AutoDisposeProviderRef; -String _$segmentPathsHash() => r'14d0fa46d736eab350f85a54908b939acd3562fd'; +String _$segmentPathsHash() => r'ffc6b402cd83f8d35eca4de7eb97113757d92135'; /// See also [_segmentPaths]. @ProviderFor(_segmentPaths) @@ -912,7 +912,7 @@ class _SegmentPathsProviderElement String get entryId => (origin as _SegmentPathsProvider).entryId; } -String _$segmentsHash() => r'4b38fe7227d758ce63b80733b122cf3a9676212f'; +String _$segmentsHash() => r'df9ff13dbbf42866bfb198f6062988d48da35ee6'; /// See also [_segments]. @ProviderFor(_segments) @@ -1058,7 +1058,7 @@ class _SegmentsProviderElement extends AutoDisposeProviderElement> String get path => (origin as _SegmentsProvider).path; } -String _$showThumbsHash() => r'54d29c90b44317760879cbb63656a53fd73cced4'; +String _$showThumbsHash() => r'6e0ffe0024b04b2b73c4703962a3e949b028a513'; /// See also [_showThumbs]. @ProviderFor(_showThumbs) @@ -1205,7 +1205,7 @@ class _ShowThumbsProviderElement extends AutoDisposeProviderElement int get endFrame => (origin as _ShowThumbsProvider).endFrame; } -String _$sliderEndOffsetHash() => r'8b6fcf6b5d98782be5d72e962e4b3f6cf7356d85'; +String _$sliderEndOffsetHash() => r'f171aff799b25d4ed9a29726a4c910af891b8765'; /// See also [_sliderEndOffset]. @ProviderFor(_sliderEndOffset) @@ -1222,7 +1222,7 @@ final _sliderEndOffsetProvider = AutoDisposeProvider.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _SliderEndOffsetRef = AutoDisposeProviderRef; -String _$sliderStartOffsetHash() => r'cea351bd17cd435ff70e20ce48f4b6e53b370445'; +String _$sliderStartOffsetHash() => r'4c988c6b8f973d9845d9f0401a3732703e003050'; /// See also [_sliderStartOffset]. @ProviderFor(_sliderStartOffset) @@ -1240,7 +1240,7 @@ final _sliderStartOffsetProvider = AutoDisposeProvider.internal( // ignore: unused_element typedef _SliderStartOffsetRef = AutoDisposeProviderRef; String _$timeFractionFramesHash() => - r'8015741ea21a16f837d627eefe543fbc6236db0f'; + r'54704d73a15014590ff9e321a98c95e2709cd572'; /// See also [_timeFractionFrames]. @ProviderFor(_timeFractionFrames) @@ -1372,7 +1372,7 @@ class _TimeFractionFramesProviderElement (origin as _TimeFractionFramesProvider).fractionModifier; } -String _$timeFractionsHash() => r'd560bc95ea61d96501c85a1c74e3eb3e22538772'; +String _$timeFractionsHash() => r'2273d4813348bc5cc3e7b8bbd17d78ab3939696c'; /// See also [_timeFractions]. @ProviderFor(_timeFractions) @@ -1389,7 +1389,7 @@ final _timeFractionsProvider = AutoDisposeProvider.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _TimeFractionsRef = AutoDisposeProviderRef; -String _$timePointOffsetHash() => r'7498c13cafb7517b374493ac38ab8e5e3a3441d0'; +String _$timePointOffsetHash() => r'1700a025ba74c3aa1ed3915791d60550dd53580d'; /// See also [_timePointOffset]. @ProviderFor(_timePointOffset) @@ -1537,7 +1537,7 @@ class _TimePointOffsetProviderElement extends AutoDisposeProviderElement } String _$totalSequenceFramesHash() => - r'd4b107ec84c284c4ccc7b90e657979daf30ea139'; + r'e756e31e18708523f758fa5e249bcf1373816394'; /// See also [_totalSequenceFrames]. @ProviderFor(_totalSequenceFrames) @@ -1555,7 +1555,7 @@ final _totalSequenceFramesProvider = AutoDisposeProvider.internal( // ignore: unused_element typedef _TotalSequenceFramesRef = AutoDisposeProviderRef; String _$trackBackgroundFractionModifierHash() => - r'e0aaee2ac472bad0bf9777a0ca67ead08a2351b3'; + r'587f3d137423aba4a2b7a75ed2490e8fc64e6836'; /// See also [_trackBackgroundFractionModifier]. @ProviderFor(_trackBackgroundFractionModifier) @@ -1574,7 +1574,7 @@ final _trackBackgroundFractionModifierProvider = // ignore: unused_element typedef _TrackBackgroundFractionModifierRef = AutoDisposeProviderRef; String _$trackBackgroundLinesHash() => - r'20ac7bd3700f1f91bd9053fb793ae6382fe9b073'; + r'78e56d8095ca6b2e615457ad2f3ec5b0bb618007'; /// See also [_trackBackgroundLines]. @ProviderFor(_trackBackgroundLines) @@ -1592,7 +1592,7 @@ final _trackBackgroundLinesProvider = @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _TrackBackgroundLinesRef = AutoDisposeProviderRef>; -String _$trackOffsetHash() => r'1f1ac2cb0fe819222d8ea488e86c896374f631a5'; +String _$trackOffsetHash() => r'30d47f3b10da598fd3a21f84b8cd840ba513ed29'; /// See also [_trackOffset]. @ProviderFor(_trackOffset) @@ -1608,7 +1608,7 @@ final _trackOffsetProvider = AutoDisposeProvider.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _TrackOffsetRef = AutoDisposeProviderRef; -String _$trackSizeHash() => r'9a61b99bd973ee4a896e962cb8b9fa690e2423a9'; +String _$trackSizeHash() => r'760f504d8f2b1f16852df36c7c44b0e7ad7adaff'; /// See also [_trackSize]. @ProviderFor(_trackSize) diff --git a/app/lib/widgets/components/app/entries_graph.dart b/app/lib/widgets/components/app/entries_graph.dart index 6441cc3330..e1563462c3 100644 --- a/app/lib/widgets/components/app/entries_graph.dart +++ b/app/lib/widgets/components/app/entries_graph.dart @@ -15,7 +15,7 @@ import "package:typewriter/widgets/components/app/search_bar.dart"; part "entries_graph.g.dart"; @riverpod -List graphableEntries(GraphableEntriesRef ref) { +List graphableEntries(Ref ref) { final page = ref.watch(currentPageProvider); if (page == null) return []; @@ -26,13 +26,13 @@ List graphableEntries(GraphableEntriesRef ref) { } @riverpod -List graphableEntryIds(GraphableEntryIdsRef ref) { +List graphableEntryIds(Ref ref) { final entries = ref.watch(graphableEntriesProvider); return entries.map((entry) => entry.id).toList(); } @riverpod -bool isTriggerEntry(IsTriggerEntryRef ref, String entryId) { +bool isTriggerEntry(Ref ref, String entryId) { final entry = ref.watch(globalEntryProvider(entryId)); if (entry == null) return false; @@ -41,7 +41,7 @@ bool isTriggerEntry(IsTriggerEntryRef ref, String entryId) { } @riverpod -bool isTriggerableEntry(IsTriggerableEntryRef ref, String entryId) { +bool isTriggerableEntry(Ref ref, String entryId) { final entry = ref.watch(globalEntryProvider(entryId)); if (entry == null) return false; @@ -50,7 +50,7 @@ bool isTriggerableEntry(IsTriggerableEntryRef ref, String entryId) { } @riverpod -Set? entryTriggers(EntryTriggersRef ref, String entryId) { +Set? entryTriggers(Ref ref, String entryId) { final entry = ref.watch(globalEntryProvider(entryId)); if (entry == null) return null; @@ -68,7 +68,7 @@ Set? entryTriggers(EntryTriggersRef ref, String entryId) { } @riverpod -Graph graph(GraphRef ref) { +Graph graph(Ref ref) { final entries = ref.watch(graphableEntriesProvider); final graph = Graph(); diff --git a/app/lib/widgets/components/app/entries_graph.g.dart b/app/lib/widgets/components/app/entries_graph.g.dart index f76782c400..bfa6be16bb 100644 --- a/app/lib/widgets/components/app/entries_graph.g.dart +++ b/app/lib/widgets/components/app/entries_graph.g.dart @@ -6,7 +6,7 @@ part of 'entries_graph.dart'; // RiverpodGenerator // ************************************************************************** -String _$graphableEntriesHash() => r'973172ce3b5839b1749880a2b05113cdbb69dc75'; +String _$graphableEntriesHash() => r'c6bd6ba93e2c2e3c07874b6762a1657826dd45b5'; /// See also [graphableEntries]. @ProviderFor(graphableEntries) @@ -23,7 +23,7 @@ final graphableEntriesProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef GraphableEntriesRef = AutoDisposeProviderRef>; -String _$graphableEntryIdsHash() => r'30455b17b0966f3f06dc65644daa50f2b50b510a'; +String _$graphableEntryIdsHash() => r'80228ea635d8a323eb54cfc0e07ea895fc2fbb5c'; /// See also [graphableEntryIds]. @ProviderFor(graphableEntryIds) @@ -40,7 +40,7 @@ final graphableEntryIdsProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef GraphableEntryIdsRef = AutoDisposeProviderRef>; -String _$isTriggerEntryHash() => r'adf2eb9cfca1541c9f2fa769d4e5d80da3216cbe'; +String _$isTriggerEntryHash() => r'593a29e659e942fc5a781652ba28e472d7f4d38a'; /// Copied from Dart SDK class _SystemHash { @@ -192,7 +192,7 @@ class _IsTriggerEntryProviderElement extends AutoDisposeProviderElement } String _$isTriggerableEntryHash() => - r'6b76b8651cf5d6a4765bbbf6c667960a3b251c83'; + r'0f48f6ff2df4d56a552745a4b59c3dd471de033c'; /// See also [isTriggerableEntry]. @ProviderFor(isTriggerableEntry) @@ -322,7 +322,7 @@ class _IsTriggerableEntryProviderElement String get entryId => (origin as IsTriggerableEntryProvider).entryId; } -String _$entryTriggersHash() => r'4ec3a031e89297970f17d2449e2ebb01022596ee'; +String _$entryTriggersHash() => r'21953b1975c1f75cb810c577c82acc59654c5555'; /// See also [entryTriggers]. @ProviderFor(entryTriggers) @@ -452,7 +452,7 @@ class _EntryTriggersProviderElement String get entryId => (origin as EntryTriggersProvider).entryId; } -String _$graphHash() => r'9bc252c6c79cef4f4b7f6e52ad1bba2e72e6c769'; +String _$graphHash() => r'e4f41f9d103b480b2d1ef7d1ba2aa3264777a45b'; /// See also [graph]. @ProviderFor(graph) diff --git a/app/lib/widgets/components/app/entry_node.dart b/app/lib/widgets/components/app/entry_node.dart index 0d475da0ce..5160fe559b 100644 --- a/app/lib/widgets/components/app/entry_node.dart +++ b/app/lib/widgets/components/app/entry_node.dart @@ -115,7 +115,6 @@ class EntryNode extends HookConsumerWidget { child: Iconify(blueprint.icon, size: 18), ), isSelected: isSelected, - isDeprecated: ref.watch(isEntryDeprecatedProvider(entryId)), contextActions: contextActions, onTap: () => ref.read(inspectingEntryIdProvider.notifier).selectEntry(entryId), @@ -203,7 +202,6 @@ class _EntryNode extends HookConsumerWidget { this.name = "", this.icon = const Icon(Icons.book, color: Colors.white), this.isSelected = false, - this.isDeprecated = false, this.contextActions = const [], this.onTap, }); @@ -213,7 +211,6 @@ class _EntryNode extends HookConsumerWidget { final String name; final Widget icon; final bool isSelected; - final bool isDeprecated; final List contextActions; final VoidCallback? onTap; @@ -268,7 +265,7 @@ class _EntryNode extends HookConsumerWidget { feedback: FakeEntryNode(entryId: id), childWhenDragging: ColoredBox( color: Theme.of(context).scaffoldBackgroundColor, - child: _placeholderEntry(context, backgroundColor), + child: _placeholderEntry(context, ref, backgroundColor), ), child: ContextMenuRegion( builder: (context) { @@ -351,7 +348,7 @@ class _EntryNode extends HookConsumerWidget { borderRadius: BorderRadius.circular(4), child: Padding( padding: const EdgeInsets.all(7.0), - child: _innerEntry(context, Colors.white), + child: _innerEntry(context, ref, Colors.white), ), ), ); @@ -390,7 +387,7 @@ class _EntryNode extends HookConsumerWidget { duration: 400.ms, curve: Curves.easeOutCirc, alignment: Alignment.topCenter, - child: _innerEntry(context, Colors.white), + child: _innerEntry(context, ref, Colors.white), ), ), ), @@ -406,7 +403,7 @@ class _EntryNode extends HookConsumerWidget { ); } - Widget _placeholderEntry(BuildContext context, Color color) { + Widget _placeholderEntry(BuildContext context, WidgetRef ref, Color color) { return ColoredBox( color: Theme.of(context).scaffoldBackgroundColor, child: DottedBorder( @@ -416,12 +413,12 @@ class _EntryNode extends HookConsumerWidget { dashPattern: const [5, 5], radius: const Radius.circular(1), padding: const EdgeInsets.all(6), - child: _innerEntry(context, color), + child: _innerEntry(context, ref, color), ), ); } - Widget _innerEntry(BuildContext context, Color color) { + Widget _innerEntry(BuildContext context, WidgetRef ref, Color color) { return Padding( padding: const EdgeInsets.all(8), child: Row( @@ -438,7 +435,9 @@ class _EntryNode extends HookConsumerWidget { fontFamily: "JetBrainsMono", fontSize: 13, color: color, - decoration: isDeprecated ? TextDecoration.lineThrough : null, + decoration: ref.watch(isEntryDeprecatedProvider(id)) + ? TextDecoration.lineThrough + : null, decorationThickness: 2.8, decorationColor: Theme.of(context).scaffoldBackgroundColor, decorationStyle: TextDecorationStyle.wavy, diff --git a/app/lib/widgets/components/app/entry_search.dart b/app/lib/widgets/components/app/entry_search.dart index a86cb8cb40..521039f5c3 100644 --- a/app/lib/widgets/components/app/entry_search.dart +++ b/app/lib/widgets/components/app/entry_search.dart @@ -205,7 +205,9 @@ Fuzzy _fuzzyBlueprints(Ref ref) { // If the blueprint has the "deprecated" tag, we don't want to show it. final blueprints = ref .watch(entryBlueprintsProvider) - .where((blueprint) => !blueprint.tags.contains("deprecated")) + .where( + (blueprint) => blueprint.modifiers.none((e) => e is DeprecatedModifier), + ) .toList(); return Fuzzy( diff --git a/app/lib/widgets/components/app/manifest_view.dart b/app/lib/widgets/components/app/manifest_view.dart index 07f685e57b..2eeab7d38b 100644 --- a/app/lib/widgets/components/app/manifest_view.dart +++ b/app/lib/widgets/components/app/manifest_view.dart @@ -15,7 +15,7 @@ import "package:typewriter/widgets/components/app/search_bar.dart"; part "manifest_view.g.dart"; @riverpod -List manifestEntries(ManifestEntriesRef ref) { +List manifestEntries(Ref ref) { final page = ref.watch(currentPageProvider); if (page == null) return []; @@ -30,13 +30,13 @@ List manifestEntries(ManifestEntriesRef ref) { } @riverpod -List manifestEntryIds(ManifestEntryIdsRef ref) { +List manifestEntryIds(Ref ref) { final entries = ref.watch(manifestEntriesProvider); return entries.map((entry) => entry.id).toList(); } @riverpod -Set? entryReferences(EntryReferencesRef ref, String entryId) { +Set? entryReferences(Ref ref, String entryId) { final entry = ref.watch(globalEntryProvider(entryId)); if (entry == null) return null; @@ -51,7 +51,7 @@ Set? entryReferences(EntryReferencesRef ref, String entryId) { } @riverpod -Graph manifestGraph(ManifestGraphRef ref) { +Graph manifestGraph(Ref ref) { final entries = ref.watch(manifestEntriesProvider); final graph = Graph(); diff --git a/app/lib/widgets/components/app/manifest_view.g.dart b/app/lib/widgets/components/app/manifest_view.g.dart index 668497d7cd..a8b68b071f 100644 --- a/app/lib/widgets/components/app/manifest_view.g.dart +++ b/app/lib/widgets/components/app/manifest_view.g.dart @@ -6,7 +6,7 @@ part of 'manifest_view.dart'; // RiverpodGenerator // ************************************************************************** -String _$manifestEntriesHash() => r'000665d0b4cf549b1875bda9c92ef01b64f1b5ce'; +String _$manifestEntriesHash() => r'a6574b7ac3e5e6d5c11cc005f907ec1e52bc2b16'; /// See also [manifestEntries]. @ProviderFor(manifestEntries) @@ -23,7 +23,7 @@ final manifestEntriesProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef ManifestEntriesRef = AutoDisposeProviderRef>; -String _$manifestEntryIdsHash() => r'a54b8e8a32fe603b535a9a30af0e4fd39d6a24ee'; +String _$manifestEntryIdsHash() => r'1877c83a8be0ccf485c94b61a342b6dfcd727bc9'; /// See also [manifestEntryIds]. @ProviderFor(manifestEntryIds) @@ -40,7 +40,7 @@ final manifestEntryIdsProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef ManifestEntryIdsRef = AutoDisposeProviderRef>; -String _$entryReferencesHash() => r'b8ca36aa7d61848c32cf0ae6af8de3fcb49a8fa2'; +String _$entryReferencesHash() => r'ba6abf603234d0956a476eda9044654727d07ef6'; /// Copied from Dart SDK class _SystemHash { @@ -191,7 +191,7 @@ class _EntryReferencesProviderElement String get entryId => (origin as EntryReferencesProvider).entryId; } -String _$manifestGraphHash() => r'91959e287dc268b2a07695aceb531654673aa878'; +String _$manifestGraphHash() => r'aaa29962a4a2753d54aa40fdfb5aedbf7f09e317'; /// See also [manifestGraph]. @ProviderFor(manifestGraph) diff --git a/app/lib/widgets/components/app/page_search.dart b/app/lib/widgets/components/app/page_search.dart index afed8e7f79..8514a0b82c 100644 --- a/app/lib/widgets/components/app/page_search.dart +++ b/app/lib/widgets/components/app/page_search.dart @@ -2,6 +2,7 @@ import "package:collection/collection.dart"; import "package:flutter/material.dart" hide Page; import "package:flutter/services.dart"; import "package:fuzzy/fuzzy.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:riverpod_annotation/riverpod_annotation.dart"; import "package:typewriter/app_router.dart"; import "package:typewriter/models/page.dart"; @@ -42,7 +43,7 @@ class PageTypeFiler extends SearchFilter { } @riverpod -Fuzzy _fuzzyPages(_FuzzyPagesRef ref) { +Fuzzy _fuzzyPages(Ref ref) { final pages = ref.watch(pagesProvider); return Fuzzy( pages, @@ -115,7 +116,7 @@ class PageFetcher extends SearchFetcher { } @riverpod -Fuzzy _fuzzyPageTypes(_FuzzyPageTypesRef ref) { +Fuzzy _fuzzyPageTypes(Ref ref) { const types = PageType.values; return Fuzzy( types, diff --git a/app/lib/widgets/components/app/page_search.g.dart b/app/lib/widgets/components/app/page_search.g.dart index af3c7ee376..1651d1100c 100644 --- a/app/lib/widgets/components/app/page_search.g.dart +++ b/app/lib/widgets/components/app/page_search.g.dart @@ -6,7 +6,7 @@ part of 'page_search.dart'; // RiverpodGenerator // ************************************************************************** -String _$fuzzyPagesHash() => r'835da172df554f740abdb580832d5be1a90aba00'; +String _$fuzzyPagesHash() => r'587e3a0f5cccbe322d7f3c74c32c43f64f871b16'; /// See also [_fuzzyPages]. @ProviderFor(_fuzzyPages) @@ -22,7 +22,7 @@ final _fuzzyPagesProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _FuzzyPagesRef = AutoDisposeProviderRef>; -String _$fuzzyPageTypesHash() => r'aad5781007f32aede23eb6288e7666f289b2f9ab'; +String _$fuzzyPageTypesHash() => r'e40fb807357ed31bb5fed21cafee566086927a39'; /// See also [_fuzzyPageTypes]. @ProviderFor(_fuzzyPageTypes) diff --git a/app/lib/widgets/components/app/search_bar.dart b/app/lib/widgets/components/app/search_bar.dart index 2d7e251f41..74f62f5c0e 100644 --- a/app/lib/widgets/components/app/search_bar.dart +++ b/app/lib/widgets/components/app/search_bar.dart @@ -34,12 +34,12 @@ final searchProvider = StateNotifierProvider( final _quantifierRegex = RegExp(r"!(\w+)"); @riverpod -FocusNode searchBarFocus(SearchBarFocusRef ref) { +Raw searchBarFocus(Ref ref) { return FocusNode(); } @riverpod -List searchElements(SearchElementsRef ref) { +List searchElements(Ref ref) { final search = ref.watch(searchProvider); if (search == null) return []; @@ -60,34 +60,34 @@ List searchElements(SearchElementsRef ref) { } @riverpod -List searchFetchers(SearchFetchersRef ref) { +List searchFetchers(Ref ref) { final search = ref.watch(searchProvider); if (search == null) return []; return search.fetchers; } @riverpod -List searchFilters(SearchFiltersRef ref) { +List searchFilters(Ref ref) { final search = ref.watch(searchProvider); if (search == null) return []; return search.filters; } @riverpod -List searchFocusNodes(SearchFocusNodesRef ref) { +List searchFocusNodes(Ref ref) { final actionsCount = ref.watch(searchElementsProvider.select((value) => value.length)); return List.generate(actionsCount, (_) => FocusNode()); } @riverpod -List searchGlobalKeys(SearchGlobalKeysRef ref) { +List searchGlobalKeys(Ref ref) { final elements = ref.watch(searchElementsProvider); return elements.map((e) => GlobalKey(debugLabel: e.title)).toList(); } @riverpod -SearchElement? _focusedElement(_FocusedElementRef ref) { +SearchElement? _focusedElement(Ref ref) { final elements = ref.watch(searchElementsProvider); final focusNodes = ref.watch(searchFocusNodesProvider); @@ -98,14 +98,14 @@ SearchElement? _focusedElement(_FocusedElementRef ref) { } @riverpod -List _searchActions(_SearchActionsRef ref) { +List _searchActions(Ref ref) { final focusedElement = ref.watch(_focusedElementProvider); return focusedElement?.actions(ref.passing) ?? []; } @riverpod -Set _searchActionShortcuts(_SearchActionShortcutsRef ref) { +Set _searchActionShortcuts(Ref ref) { final elements = ref.watch(searchElementsProvider); final activators = elements .expand((e) => e.actions(ref.passing)) @@ -373,7 +373,7 @@ abstract class SearchFetcher { bool get disabled; String get icon => TWIcons.magnifyingGlass; - /// Quantifiers are used to disable the fetcher using !. + /// Quantifiers are used to disable the fetcher using !\. /// When a quantifier is used, the fetcher will only be used if the search contains the quantifier. List get quantifiers => const []; diff --git a/app/lib/widgets/components/app/search_bar.g.dart b/app/lib/widgets/components/app/search_bar.g.dart index 3b8d0a0ea5..8192e3640d 100644 --- a/app/lib/widgets/components/app/search_bar.g.dart +++ b/app/lib/widgets/components/app/search_bar.g.dart @@ -6,11 +6,11 @@ part of 'search_bar.dart'; // RiverpodGenerator // ************************************************************************** -String _$searchBarFocusHash() => r'6c71ae13ae8438aae434c6aba9dc6e1bc575a252'; +String _$searchBarFocusHash() => r'53f335a0b446f290510ba4846f6770a24e7bfdf8'; /// See also [searchBarFocus]. @ProviderFor(searchBarFocus) -final searchBarFocusProvider = AutoDisposeProvider.internal( +final searchBarFocusProvider = AutoDisposeProvider>.internal( searchBarFocus, name: r'searchBarFocusProvider', debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') @@ -22,8 +22,8 @@ final searchBarFocusProvider = AutoDisposeProvider.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element -typedef SearchBarFocusRef = AutoDisposeProviderRef; -String _$searchElementsHash() => r'27e44baceaa5af3207c348ebea9bcc1ac2a63672'; +typedef SearchBarFocusRef = AutoDisposeProviderRef>; +String _$searchElementsHash() => r'ec61a24143ff846911649d995c31476e9fdded7e'; /// See also [searchElements]. @ProviderFor(searchElements) @@ -41,7 +41,7 @@ final searchElementsProvider = @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef SearchElementsRef = AutoDisposeProviderRef>; -String _$searchFetchersHash() => r'2d5cadf196e4124536a572332a4fee5e52f107e1'; +String _$searchFetchersHash() => r'59f2abe2be8f801461e8e097a61651fdd1885913'; /// See also [searchFetchers]. @ProviderFor(searchFetchers) @@ -59,7 +59,7 @@ final searchFetchersProvider = @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef SearchFetchersRef = AutoDisposeProviderRef>; -String _$searchFiltersHash() => r'7f0eaee452766397d6cbd49a4a6389c2df9ee84e'; +String _$searchFiltersHash() => r'a46fcda7bd526da1154e9efdd5e24a69a69ae924'; /// See also [searchFilters]. @ProviderFor(searchFilters) @@ -76,7 +76,7 @@ final searchFiltersProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef SearchFiltersRef = AutoDisposeProviderRef>; -String _$searchFocusNodesHash() => r'e8f229dddc824b6f24244adcd4193ae40daed175'; +String _$searchFocusNodesHash() => r'7ff4c000a2349a964ff56d6390e3520c912c217c'; /// See also [searchFocusNodes]. @ProviderFor(searchFocusNodes) @@ -93,7 +93,7 @@ final searchFocusNodesProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef SearchFocusNodesRef = AutoDisposeProviderRef>; -String _$searchGlobalKeysHash() => r'bdabd3beff37b339bab7032a03c48a3714ac500f'; +String _$searchGlobalKeysHash() => r'b7d07803139dfa9fd0249a16527402e80c99d0b7'; /// See also [searchGlobalKeys]. @ProviderFor(searchGlobalKeys) @@ -110,7 +110,7 @@ final searchGlobalKeysProvider = AutoDisposeProvider>.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef SearchGlobalKeysRef = AutoDisposeProviderRef>; -String _$focusedElementHash() => r'30e569a4d12a0f28f496a0e235319f5e5e44e433'; +String _$focusedElementHash() => r'680f35cbfe9c48b0ac86cdf5dad00e897a42cd11'; /// See also [_focusedElement]. @ProviderFor(_focusedElement) @@ -127,7 +127,7 @@ final _focusedElementProvider = AutoDisposeProvider.internal( @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element typedef _FocusedElementRef = AutoDisposeProviderRef; -String _$searchActionsHash() => r'b5542c6b01dc4d9186c38a2ef1453cbb8bc2eede'; +String _$searchActionsHash() => r'2ff49d3c872ae2d9db7ef13696761fa7fa4b2a88'; /// See also [_searchActions]. @ProviderFor(_searchActions) @@ -145,7 +145,7 @@ final _searchActionsProvider = AutoDisposeProvider>.internal( // ignore: unused_element typedef _SearchActionsRef = AutoDisposeProviderRef>; String _$searchActionShortcutsHash() => - r'e3fbc98277d831182b5690cae7d29278bb67ccdc'; + r'c40d8abbd6ba50fbe0fcace8ab587dca55e10c54'; /// See also [_searchActionShortcuts]. @ProviderFor(_searchActionShortcuts) diff --git a/app/lib/widgets/inspector/editors/generic.dart b/app/lib/widgets/inspector/editors/generic.dart index 073714d07f..b86d95b977 100644 --- a/app/lib/widgets/inspector/editors/generic.dart +++ b/app/lib/widgets/inspector/editors/generic.dart @@ -45,8 +45,6 @@ class GenericEditor extends HookConsumerWidget { blueprint = generic.dataBlueprint; } - print("Generic blueprint: $blueprint"); - return FieldEditor(path: path, dataBlueprint: blueprint); } diff --git a/app/lib/widgets/inspector/editors/list.dart b/app/lib/widgets/inspector/editors/list.dart index 743d267150..241016e84d 100644 --- a/app/lib/widgets/inspector/editors/list.dart +++ b/app/lib/widgets/inspector/editors/list.dart @@ -28,7 +28,7 @@ class ListEditorFilter extends EditorFilter { } @riverpod -int _listValueLength(_ListValueLengthRef ref, String path) { +int _listValueLength(Ref ref, String path) { return (ref.watch(fieldValueProvider(path)) as List? ?? []).length; } @@ -106,6 +106,8 @@ class ListEditor extends HookConsumerWidget { _reorderList(globalKeys, oldIndex, newIndex); }, shrinkWrap: true, + // The Inspector is already scrollable, so we don't want this to be nested. + physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) => _ListItem( key: globalKeys[index], index: index, diff --git a/app/lib/widgets/inspector/editors/list.g.dart b/app/lib/widgets/inspector/editors/list.g.dart index aab5191043..ef978b305f 100644 --- a/app/lib/widgets/inspector/editors/list.g.dart +++ b/app/lib/widgets/inspector/editors/list.g.dart @@ -6,7 +6,7 @@ part of 'list.dart'; // RiverpodGenerator // ************************************************************************** -String _$listValueLengthHash() => r'df97a1cf8a545d4290a4ebda9f64f91deaf9e8e9'; +String _$listValueLengthHash() => r'8ceeffa37d6f86207ba05ad7d0b99adb477fcf2f'; /// Copied from Dart SDK class _SystemHash { diff --git a/app/lib/widgets/inspector/editors/material.dart b/app/lib/widgets/inspector/editors/material.dart index 9495ee2f44..74485a79ad 100644 --- a/app/lib/widgets/inspector/editors/material.dart +++ b/app/lib/widgets/inspector/editors/material.dart @@ -21,7 +21,7 @@ typedef CombinedMaterial = MapEntry; @riverpod List materialProperties( - MaterialPropertiesRef ref, + Ref ref, String meta, ) { return meta @@ -36,7 +36,7 @@ List materialProperties( } @riverpod -Fuzzy _fuzzyMaterials(_FuzzyMaterialsRef ref) { +Fuzzy _fuzzyMaterials(Ref ref) { return Fuzzy( materials.entries.toList(), options: FuzzyOptions( diff --git a/app/lib/widgets/inspector/editors/material.g.dart b/app/lib/widgets/inspector/editors/material.g.dart index 95f1de0c16..5ca299896c 100644 --- a/app/lib/widgets/inspector/editors/material.g.dart +++ b/app/lib/widgets/inspector/editors/material.g.dart @@ -7,7 +7,7 @@ part of 'material.dart'; // ************************************************************************** String _$materialPropertiesHash() => - r'ec0ce652cc3458c9e2ee4d54c4fa1f496a45f1db'; + r'06bdf69c856589203d392aba18d7a6aa9eec115b'; /// Copied from Dart SDK class _SystemHash { @@ -160,7 +160,7 @@ class _MaterialPropertiesProviderElement String get meta => (origin as MaterialPropertiesProvider).meta; } -String _$fuzzyMaterialsHash() => r'bfaa303c86894a2592b383e46588f82a7a8b7e6d'; +String _$fuzzyMaterialsHash() => r'b37a1dfd121ba671b25989280ff20c0c1bd9c1f8'; /// See also [_fuzzyMaterials]. @ProviderFor(_fuzzyMaterials) diff --git a/app/lib/widgets/inspector/editors/potion_effect.dart b/app/lib/widgets/inspector/editors/potion_effect.dart index db20e7343d..9bc62671c6 100644 --- a/app/lib/widgets/inspector/editors/potion_effect.dart +++ b/app/lib/widgets/inspector/editors/potion_effect.dart @@ -22,7 +22,7 @@ String _potionEffectIconUrl(String potionEffect) { } @riverpod -Fuzzy _fuzzyPotionEffects(_FuzzyPotionEffectsRef ref) { +Fuzzy _fuzzyPotionEffects(Ref ref) { final provider = ref.watch(potionEffectsProvider); final effects = provider.map( data: (data) => data.value, diff --git a/app/lib/widgets/inspector/editors/potion_effect.g.dart b/app/lib/widgets/inspector/editors/potion_effect.g.dart index 040b572268..3b5420fbec 100644 --- a/app/lib/widgets/inspector/editors/potion_effect.g.dart +++ b/app/lib/widgets/inspector/editors/potion_effect.g.dart @@ -7,7 +7,7 @@ part of 'potion_effect.dart'; // ************************************************************************** String _$fuzzyPotionEffectsHash() => - r'570bdd0a31305bc22b850457bd1ac5322439ac62'; + r'2c95902eeb701e1aa675683ea541e754466d9cc0'; /// See also [_fuzzyPotionEffects]. @ProviderFor(_fuzzyPotionEffects) diff --git a/app/lib/widgets/inspector/editors/sound_id.dart b/app/lib/widgets/inspector/editors/sound_id.dart index 8f43569270..5cb0176e97 100644 --- a/app/lib/widgets/inspector/editors/sound_id.dart +++ b/app/lib/widgets/inspector/editors/sound_id.dart @@ -26,7 +26,7 @@ import "package:typewriter/widgets/inspector/inspector.dart"; part "sound_id.g.dart"; @riverpod -Fuzzy _fuzzyMinecraftSounds(_FuzzyMinecraftSoundsRef ref) { +Fuzzy _fuzzyMinecraftSounds(Ref ref) { final provider = ref.watch(minecraftSoundsProvider); final sounds = provider.map( data: (data) => data.value.entries.toList(), diff --git a/app/lib/widgets/inspector/editors/sound_id.g.dart b/app/lib/widgets/inspector/editors/sound_id.g.dart index 19eb8c8ce7..058fffb848 100644 --- a/app/lib/widgets/inspector/editors/sound_id.g.dart +++ b/app/lib/widgets/inspector/editors/sound_id.g.dart @@ -7,7 +7,7 @@ part of 'sound_id.dart'; // ************************************************************************** String _$fuzzyMinecraftSoundsHash() => - r'0399119149fbb7dede77651afb4ce9f0dd6220c6'; + r'5819dd8cd552203ef558bc138611509bd4f68388'; /// See also [_fuzzyMinecraftSounds]. @ProviderFor(_fuzzyMinecraftSounds) diff --git a/app/lib/widgets/inspector/heading.dart b/app/lib/widgets/inspector/heading.dart index 7b6ca300bc..26e6e2b1e4 100644 --- a/app/lib/widgets/inspector/heading.dart +++ b/app/lib/widgets/inspector/heading.dart @@ -54,7 +54,7 @@ class Heading extends HookConsumerWidget { final type = ref.watch(_entryTypeProvider); final url = ref.watch(_entryUrlProvider); final color = ref.watch(_entryColorProvider); - final isDeprecated = ref.watch(isEntryDeprecatedProvider(id)); + final deprecation = ref.watch(entryDeprecatedProvider(id)); return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -62,7 +62,7 @@ class Heading extends HookConsumerWidget { Title( color: color, title: name, - isDeprecated: isDeprecated, + isDeprecated: deprecation != null, ), Wrap( spacing: 8, @@ -74,9 +74,9 @@ class Heading extends HookConsumerWidget { EntryIdentifier(id: id), ], ), - if (isDeprecated) ...[ + if (deprecation != null) ...[ const SizedBox(height: 8), - _DeperecationWarning(url: url), + _DeperecationWarning(url: url, reason: deprecation.reason), ], ], ); @@ -174,9 +174,11 @@ class EntryBlueprintDisplay extends HookConsumerWidget { class _DeperecationWarning extends StatelessWidget { const _DeperecationWarning({ required this.url, + required this.reason, }); final String url; + final String reason; Future _launceUrl() async { if (url.isEmpty) return; @@ -188,7 +190,7 @@ class _DeperecationWarning extends StatelessWidget { Widget build(BuildContext context) { return Admonition.danger( onTap: _launceUrl, - child: const Text.rich( + child: Text.rich( TextSpan( text: "This entry has been marked as deprecated. Take a look at the ", children: [ @@ -200,6 +202,15 @@ class _DeperecationWarning extends StatelessWidget { ), ), TextSpan(text: " for more information."), + if (reason.isNotEmpty) ...[ + TextSpan( + text: "\n$reason", + style: TextStyle( + color: Colors.redAccent, + fontWeight: FontWeight.bold, + ), + ), + ], ], ), ), diff --git a/app/lib/widgets/inspector/inspector.dart b/app/lib/widgets/inspector/inspector.dart index e752fb6079..6aab8673a6 100644 --- a/app/lib/widgets/inspector/inspector.dart +++ b/app/lib/widgets/inspector/inspector.dart @@ -44,7 +44,7 @@ final inspectingEntryIdProvider = ); @riverpod -Entry? inspectingEntry(InspectingEntryRef ref) { +Entry? inspectingEntry(Ref ref) { final selectedEntryId = ref.watch(inspectingEntryIdProvider); if (selectedEntryId == null) return null; return ref.watch(globalEntryProvider(selectedEntryId)); @@ -93,7 +93,7 @@ class EmptyInspector extends HookConsumerWidget { } @riverpod -EntryDefinition? inspectingEntryDefinition(InspectingEntryDefinitionRef ref) { +EntryDefinition? inspectingEntryDefinition(Ref ref) { final entryId = ref.watch(inspectingEntryIdProvider); if (entryId.isNullOrEmpty) { diff --git a/app/lib/widgets/inspector/inspector.g.dart b/app/lib/widgets/inspector/inspector.g.dart index bb3ce0ce7a..92425ce7e7 100644 --- a/app/lib/widgets/inspector/inspector.g.dart +++ b/app/lib/widgets/inspector/inspector.g.dart @@ -6,7 +6,7 @@ part of 'inspector.dart'; // RiverpodGenerator // ************************************************************************** -String _$inspectingEntryHash() => r'b411aee990e39a0dbcee5aee43a8b40d7a5c63f6'; +String _$inspectingEntryHash() => r'9ef0b12c7322ca3271fcf0f3439e1ae57e8d435a'; /// See also [inspectingEntry]. @ProviderFor(inspectingEntry) @@ -24,7 +24,7 @@ final inspectingEntryProvider = AutoDisposeProvider.internal( // ignore: unused_element typedef InspectingEntryRef = AutoDisposeProviderRef; String _$inspectingEntryDefinitionHash() => - r'20a2722e89b0eccb897db82f076db9dcaf9055fa'; + r'936136d8fec8f78e73cb6e302cdaca1ce01032ec'; /// See also [inspectingEntryDefinition]. @ProviderFor(inspectingEntryDefinition) diff --git a/app/lib/widgets/inspector/operations.dart b/app/lib/widgets/inspector/operations.dart index e9516f9221..56c40368a2 100644 --- a/app/lib/widgets/inspector/operations.dart +++ b/app/lib/widgets/inspector/operations.dart @@ -126,7 +126,6 @@ class _DuplicateEntry extends HookConsumerWidget { if (page == null) return; final entryId = ref.read(inspectingEntryIdProvider); if (entryId.isNullOrEmpty) return; - print("Creating duplicate entry"); page.duplicateEntry(ref.passing, entryId!); }, icon: const Iconify(TWIcons.duplicate), diff --git a/app/test/page_test.dart b/app/test/page_test.dart index b5d7eaa84c..9c48521b68 100644 --- a/app/test/page_test.dart +++ b/app/test/page_test.dart @@ -84,7 +84,11 @@ void main() { dataBlueprint: entryBlueprintFields, ); - await page.createEntryFromBlueprint(container.passing, entry); + await page.createEntryFromBlueprint( + container.passing, + entry, + genericBlueprint: null, + ); final newPage = container.read(pageProvider(page.id)); diff --git a/engine/engine-core/src/main/kotlin/com/typewritermc/core/entries/Library.kt b/engine/engine-core/src/main/kotlin/com/typewritermc/core/entries/Library.kt index e337a1bc84..df50b9ed19 100644 --- a/engine/engine-core/src/main/kotlin/com/typewritermc/core/entries/Library.kt +++ b/engine/engine-core/src/main/kotlin/com/typewritermc/core/entries/Library.kt @@ -11,6 +11,7 @@ import org.koin.core.component.inject import org.koin.core.qualifier.named import java.io.File import java.util.logging.Logger +import kotlin.reflect.full.findAnnotations class Library : KoinComponent, Reloadable { internal var pages: List = emptyList() @@ -78,13 +79,25 @@ class Library : KoinComponent, Reloadable { val clazz = extensionLoader.entryClass(blueprintId) .logErrorIfNull("Could not find entry class for '$id' on page '${pageName}' with type '$blueprintId' in any extension.") ?: return null try { - return gson.fromJson(obj, clazz) + val entry = gson.fromJson(obj, clazz) + entryValidation(entry, pageName, blueprintId) + return entry } catch (e: Exception) { logger.warning("Failed to parse entry '$id' with blueprintId '$blueprintId' on page '${pageName}': ${e.message}") return null } } + private fun entryValidation(entry: Entry, pageName: String, blueprintId: String) { + deprecatedEntryValidation(entry, pageName, blueprintId) + } + + private fun deprecatedEntryValidation(entry: Entry, pageName: String, blueprintId: String) { + // If the entry has the @Deprecated annotation, we want to warn the user about it. + val deprecated = entry::class.findAnnotations().firstOrNull() ?: return + logger.warning("Entry '${entry.id}' on page '${pageName}' with blueprintId '$blueprintId' is deprecated and will be removed in the future. Reason: ${deprecated.message}") + } + private fun T?.logErrorIfNull(message: String): T? { if (this == null) { logger.severe(message) diff --git a/module-plugin/extension-processor/src/main/kotlin/com/typewritermc/processors/entry/EntryProcessor.kt b/module-plugin/extension-processor/src/main/kotlin/com/typewritermc/processors/entry/EntryProcessor.kt index 622db9862c..3c0d05bd98 100644 --- a/module-plugin/extension-processor/src/main/kotlin/com/typewritermc/processors/entry/EntryProcessor.kt +++ b/module-plugin/extension-processor/src/main/kotlin/com/typewritermc/processors/entry/EntryProcessor.kt @@ -7,6 +7,7 @@ import com.google.devtools.ksp.processing.KSPLogger import com.google.devtools.ksp.processing.Resolver import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSClassDeclaration +import com.google.devtools.ksp.symbol.KSPropertyDeclaration import com.typewritermc.SharedJsonManager import com.typewritermc.core.extension.annotations.Entry import com.typewritermc.core.extension.annotations.GenericConstraint @@ -16,6 +17,7 @@ import com.typewritermc.moduleplugin.TypewriterExtensionConfiguration import com.typewritermc.processors.ExtensionPartProcessor import com.typewritermc.processors.annotationClassValue import com.typewritermc.processors.fullName +import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.JsonElement @@ -52,12 +54,13 @@ class EntryProcessor( description = annotation.description, color = annotation.color, icon = annotation.icon, + className = clazz.qualifiedName?.asString() ?: throw IllegalClassTypeException(clazz.simpleName.asString()), + extension = configuration.name, tags = clazz.tags, dataBlueprint = dataBlueprint, genericConstraints = clazz.genericConstraints(dataBlueprint), variableDataBlueprint = clazz.variableDataBlueprint(), - className = clazz.qualifiedName?.asString() ?: throw IllegalClassTypeException(clazz.simpleName.asString()), - extension = configuration.name, + modifiers = clazz.getModifiers(), ) return blueprintJson.encodeToJsonElement(blueprint) @@ -135,6 +138,16 @@ class EntryProcessor( return blueprint } } + + @OptIn(KspExperimental::class) + private fun KSClassDeclaration.getModifiers(): List { + val modifiers = mutableListOf() + val annotation = this.getAnnotationsByType(Deprecated::class).firstOrNull() + if (annotation != null) { + modifiers.add(EntryModifier.Deprecated(annotation.message)) + } + return modifiers + } } @Serializable @@ -144,14 +157,23 @@ private data class EntryBlueprint( val description: String, val color: String, val icon: String, + val className: String, + val extension: String, val tags: List, val dataBlueprint: DataBlueprint, val genericConstraints: List?, val variableDataBlueprint: DataBlueprint?, - val className: String, - val extension: String, + val modifiers: List, ) +@Serializable +sealed interface EntryModifier { + @Serializable + @SerialName("deprecated") + class Deprecated(val reason: String) : EntryModifier +} + + class IllegalClassTypeException(className: String) : Exception("Class $className does not have a qualified name. Entry classes must be full classes.")