-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from Wolfteam/feature/materials
feature/materials
- Loading branch information
Showing
70 changed files
with
7,362 additions
and
1,162 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/cupertino.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:genshindb/application/common/pop_bloc.dart'; | ||
import 'package:genshindb/domain/enums/enums.dart'; | ||
import 'package:genshindb/domain/models/models.dart'; | ||
import 'package:genshindb/domain/services/genshin_service.dart'; | ||
import 'package:genshindb/domain/services/telemetry_service.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
part 'material_bloc.freezed.dart'; | ||
part 'material_event.dart'; | ||
part 'material_state.dart'; | ||
|
||
class MaterialBloc extends PopBloc<MaterialEvent, MaterialState> { | ||
final GenshinService _genshinService; | ||
final TelemetryService _telemetryService; | ||
|
||
MaterialBloc(this._genshinService, this._telemetryService) : super(const MaterialState.loading()); | ||
|
||
@override | ||
MaterialEvent getEventForPop(String key) => MaterialEvent.loadFromName(key: key, addToQueue: false); | ||
|
||
@override | ||
Stream<MaterialState> mapEventToState(MaterialEvent event) async* { | ||
final s = await event.map( | ||
loadFromName: (e) async { | ||
final material = _genshinService.getMaterial(e.key); | ||
if (e.addToQueue) { | ||
await _telemetryService.trackMaterialLoaded(e.key); | ||
currentItemsInStack.add(material.key); | ||
} | ||
return _buildInitialState(material); | ||
}, | ||
loadFromImg: (e) async { | ||
final material = _genshinService.getMaterialByImage(e.image); | ||
if (e.addToQueue) { | ||
await _telemetryService.trackMaterialLoaded(material.image, loadedFromName: false); | ||
currentItemsInStack.add(material.key); | ||
} | ||
return _buildInitialState(material); | ||
}, | ||
); | ||
|
||
yield s; | ||
} | ||
|
||
MaterialState _buildInitialState(MaterialFileModel material) { | ||
final translation = _genshinService.getMaterialTranslation(material.key); | ||
final charImgs = _genshinService.getCharacterImgsUsingMaterial(material.key); | ||
final weaponImgs = _genshinService.getWeaponImgsUsingMaterial(material.key); | ||
final relatedMaterials = _genshinService.getRelatedMaterialImgsToMaterial(material.key); | ||
return MaterialState.loaded( | ||
name: translation.name, | ||
fullImage: material.fullImagePath, | ||
rarity: material.rarity, | ||
type: material.type, | ||
description: translation.description, | ||
charImages: charImgs, | ||
weaponImages: weaponImgs, | ||
days: material.days, | ||
obtainedFrom: material.obtainedFrom, | ||
relatedMaterials: relatedMaterials, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
part of 'material_bloc.dart'; | ||
|
||
@freezed | ||
abstract class MaterialEvent implements _$MaterialEvent { | ||
const factory MaterialEvent.loadFromName({ | ||
@required String key, | ||
@Default(true) bool addToQueue, | ||
}) = _LoadMaterialFromName; | ||
|
||
const factory MaterialEvent.loadFromImg({ | ||
@required String image, | ||
@Default(true) bool addToQueue, | ||
}) = _LoadMaterialFromImg; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
part of 'material_bloc.dart'; | ||
|
||
@freezed | ||
abstract class MaterialState implements _$MaterialState { | ||
const factory MaterialState.loading() = _LoadingState; | ||
const factory MaterialState.loaded({ | ||
@required String name, | ||
@required String fullImage, | ||
@required int rarity, | ||
@required MaterialType type, | ||
String description, | ||
@required List<String> charImages, | ||
@required List<String> weaponImages, | ||
@required List<int> days, | ||
@required List<ObtainedFromFileModel> obtainedFrom, | ||
@required List<String> relatedMaterials, | ||
}) = _LoadedState; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
part of 'materials_bloc.dart'; | ||
|
||
@freezed | ||
abstract class MaterialsEvent with _$MaterialsEvent { | ||
abstract class MaterialsEvent implements _$MaterialsEvent { | ||
const factory MaterialsEvent.init() = _Init; | ||
const factory MaterialsEvent.searchChanged({ | ||
@required String search, | ||
}) = _SearchChanged; | ||
|
||
const factory MaterialsEvent.rarityChanged(int rarity) = _RarityChanged; | ||
const factory MaterialsEvent.typeChanged(MaterialType type) = _TypeChanged; | ||
const factory MaterialsEvent.filterTypeChanged(MaterialFilterType type) = _FilterTypeChanged; | ||
const factory MaterialsEvent.applyFilterChanges() = _ApplyFilterChanges; | ||
const factory MaterialsEvent.sortDirectionTypeChanged(SortDirectionType sortDirectionType) = _SortDirectionTypeChanged; | ||
|
||
const factory MaterialsEvent.cancelChanges() = _CancelChanges; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
part of 'materials_bloc.dart'; | ||
|
||
@freezed | ||
abstract class MaterialsState with _$MaterialsState { | ||
abstract class MaterialsState implements _$MaterialsState { | ||
const factory MaterialsState.loading() = _LoadingState; | ||
|
||
const factory MaterialsState.loaded({ | ||
@required List<TodayCharAscensionMaterialsModel> charAscMaterials, | ||
@required List<TodayWeaponAscensionMaterialModel> weaponAscMaterials, | ||
@required List<MaterialCardModel> materials, | ||
String search, | ||
@required int rarity, | ||
@required int tempRarity, | ||
@required MaterialFilterType filterType, | ||
@required MaterialFilterType tempFilterType, | ||
@required MaterialType type, | ||
@required MaterialType tempType, | ||
@required SortDirectionType sortDirectionType, | ||
@required SortDirectionType tempSortDirectionType, | ||
}) = _LoadedState; | ||
} |
Oops, something went wrong.