Skip to content

Commit 2a68553

Browse files
Add sound page (#51)
* Add basic implementation of the SoundEventModel * Add related parts to manage SoundModelEvents in the app state * Add more state management related code for sounds * Add client api to handle data manipulation for sounds # Conflicts: # lib/api/api_service.dart * Rename some actions to reflect their context * Improve sound state classes * Improve some SoundActions * Add route for the sound page * Add SoundFileSource file * Add basic implementation to view data for a sound * Improve base layout for sounds * Add mockup dialog for the sound file editing * Update SoundFileSource class * Work on the sound modal page * Remove Expanded usage to avoid a stacktrace * Add new methods to the SelectedSoundView class * Add FolderIcon widget implementation * Add SmallFileCard widget * Improve widget structure * Add stateless widget for the view button on a SoundCard * Add SoundCardButton usage * Remove Padding and update EdgeInsets value * Update api calls * Update hasFiles getter to hasNoFiles * Include SoundFileSource list to the SoundEventModel * Add client api to handle data manipulation for sounds * Add optional SoundFileSource variable to the event model * Update hasFiles to hasNoFiles * Remove fontWeight usage * Improve TextInputCard creation * Add sound enum entry for the navigation * Add input formatters * Add VolumeSection class * Add SoundSlider class * Update slider usage * Improve widget structure * Add pagination to the SoundEventModel * Update Sound api handling * Improve sound related redux actions * Improve vm state for the selected sound * Improve paginated list * Update imports * Work on pagination * Rebuild some freezed files to avoid future conflicts * Fix some lint commits * Use initialValue instead of the deprecated value parameter * Add base section widget * Update section widgets * Add input section widget for strings * Update widget usage * Update parameter list for a function * Store SoundEvent in a PaginatedResult instead of a list * Update sound vm state * Add static access methods * Update item access in the sound actions * Update action calls * Switch root widget to PaginatedBaseModelViewTabs * Improve validator usage * Add unit test for the folder icon * Add constant value for a magic number * Add missing query parameters for a pageable request * Remove as call * Add lazy load to the sound files page * Add keep file * Improve state handling * Adjust min, max and division values to align them with the sound protocol specification from Minecraft * Add custom value formatter to deal better with minimal default values * Add test cases for the min value formatter * Improve input formatting handling * Improve widget handling * Update imports * Improve dialog usage * Update logic to link a source file with an event * Improve dialog handling to allow the update of existing sound sources * Add endpoint and redux action to update a SoundFileSource * Improve dialog handling when a existing model should be updated * Retrieve given id from the old model before creating a new one without an id * Fix cancel button usage * Add api and redux action to delete a sound file source * Implement test wise the delete logic * Update delete endpoint usage for SoundSourceFiles * Add generic tooltip message * Fix file naming --------- Co-authored-by: theEvilReaper <[email protected]> Co-authored-by: Joltras <[email protected]>
1 parent 2bdb1fa commit 2a68553

39 files changed

+2943
-38
lines changed

lib/api/api_service.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:stelaris/api/api_client.dart';
22
import 'package:stelaris/api/base_api.dart';
3+
import 'package:stelaris/api/service/client/sound_client_api.dart';
34
import 'package:stelaris/api/client_api.dart';
5+
import 'package:stelaris/api/model/sound/sound_event_model.dart';
46
import 'package:stelaris/api/model/attribute_model.dart';
57
import 'package:stelaris/api/model/notification_model.dart';
68
import 'package:stelaris/api/service/font_api.dart';
@@ -40,6 +42,10 @@ class ApiService {
4042
toJson: (model) => model.toJson(),
4143
);
4244

45+
late final ClientAPI<SoundEventModel> soundApi = SoundClientApi(
46+
apiClient: _apiClient,
47+
);
48+
4349
/// Creates an instance of [ApiClient] with the backend URL.
4450
ApiClient _createApiClient() => ApiClient(Environment.backendURl);
4551

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import 'package:freezed_annotation/freezed_annotation.dart';
2+
import 'package:stelaris/api/model/data_model.dart';
3+
import 'package:stelaris/api/model/sound/sound_file_source.dart';
4+
import 'package:stelaris/api/paginated_result.dart';
5+
6+
part 'sound_event_model.freezed.dart';
7+
8+
part 'sound_event_model.g.dart';
9+
10+
SoundEventModel soundEventFromJson(dynamic json) =>
11+
SoundEventModel.fromJson(json);
12+
13+
Map<String, dynamic> soundEventToJson(SoundEventModel model) => model.toJson();
14+
15+
@freezed
16+
abstract class SoundEventModel with _$SoundEventModel, DataModel {
17+
const SoundEventModel._();
18+
19+
// Define the specific const default directly within the class that uses it.
20+
// This is well-encapsulated.
21+
static const PaginatedResult<SoundFileSource> _defaultFiles = PaginatedResult(
22+
items: <SoundFileSource>[],
23+
totalItems: 0,
24+
totalPages: 0,
25+
currentPage: 1,
26+
pageSize: 0,
27+
);
28+
29+
factory SoundEventModel({
30+
required String uiName,
31+
String? id,
32+
String? variableName,
33+
String? keyName,
34+
String? subTitle,
35+
@Default(SoundEventModel._defaultFiles)
36+
PaginatedResult<SoundFileSource> files,
37+
@Default(false) @JsonKey(includeToJson: false) bool isLoading,
38+
}) = _SoundEventModel;
39+
40+
factory SoundEventModel.fromJson(Map<String, dynamic> json) =>
41+
_$SoundEventModelFromJson(json);
42+
}

lib/api/model/sound/sound_event_model.freezed.dart

Lines changed: 295 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/api/model/sound/sound_event_model.g.dart

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)