diff --git a/lib/application/calculator_asc_materials/calculator_asc_materials_bloc.dart b/lib/application/calculator_asc_materials/calculator_asc_materials_bloc.dart index db9d13497..fb1d0ee22 100644 --- a/lib/application/calculator_asc_materials/calculator_asc_materials_bloc.dart +++ b/lib/application/calculator_asc_materials/calculator_asc_materials_bloc.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:genshindb/domain/app_constants.dart'; import 'package:genshindb/domain/assets.dart'; import 'package:genshindb/domain/enums/enums.dart'; import 'package:genshindb/domain/models/models.dart'; @@ -41,10 +42,12 @@ class CalculatorAscMaterialsBloc extends Bloc i.materials).toList())); @@ -77,10 +82,12 @@ class CalculatorAscMaterialsBloc extends Bloc _getCharacterMaterialsToUse( CharacterFileModel char, - int currentLevel, - int desiredLevel, + int currentAscensionLevel, + int desiredAscensionLevel, List skills, ) { final ascensionMaterials = - char.ascensionMaterials.where((m) => m.rank > currentLevel && m.rank <= desiredLevel).expand((e) => e.materials).toList(); + char.ascensionMaterials.where((m) => m.rank > currentAscensionLevel && m.rank <= desiredAscensionLevel).expand((e) => e.materials).toList(); final skillMaterials = []; @@ -218,11 +228,11 @@ class CalculatorAscMaterialsBloc extends Bloc _getWeaponMaterialsToUse( WeaponFileModel weapon, - int currentLevel, - int desiredLevel, + int currentAscensionLevel, + int desiredAscensionLevel, ) { final materials = weapon.ascensionMaterials - .where((m) => m.level > _mapToWeaponLevel(currentLevel) && m.level <= _mapToWeaponLevel(desiredLevel)) + .where((m) => m.level > _mapToWeaponLevel(currentAscensionLevel) && m.level <= _mapToWeaponLevel(desiredAscensionLevel)) .expand((m) => m.materials) .toList(); @@ -254,20 +264,9 @@ class CalculatorAscMaterialsBloc extends Bloc kvp.key == val); + return entry.value; } } } diff --git a/lib/application/calculator_asc_materials/calculator_asc_materials_event.dart b/lib/application/calculator_asc_materials/calculator_asc_materials_event.dart index b9297d7a0..f2d3040dd 100644 --- a/lib/application/calculator_asc_materials/calculator_asc_materials_event.dart +++ b/lib/application/calculator_asc_materials/calculator_asc_materials_event.dart @@ -8,6 +8,8 @@ abstract class CalculatorAscMaterialsEvent with _$CalculatorAscMaterialsEvent { @required String key, @required int currentLevel, @required int desiredLevel, + @required int currentAscensionLevel, + @required int desiredAscensionLevel, @required List skills, }) = _AddCharacter; @@ -15,6 +17,8 @@ abstract class CalculatorAscMaterialsEvent with _$CalculatorAscMaterialsEvent { @required int index, @required int currentLevel, @required int desiredLevel, + @required int currentAscensionLevel, + @required int desiredAscensionLevel, @required List skills, }) = _UpdateCharacter; @@ -22,12 +26,16 @@ abstract class CalculatorAscMaterialsEvent with _$CalculatorAscMaterialsEvent { @required String key, @required int currentLevel, @required int desiredLevel, + @required int currentAscensionLevel, + @required int desiredAscensionLevel, }) = _AddWeapon; const factory CalculatorAscMaterialsEvent.updateWeapon({ @required int index, @required int currentLevel, @required int desiredLevel, + @required int currentAscensionLevel, + @required int desiredAscensionLevel, }) = _UpdateWeapon; const factory CalculatorAscMaterialsEvent.removeItem({ diff --git a/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_bloc.dart b/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_bloc.dart index dce463859..220adae93 100644 --- a/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_bloc.dart +++ b/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_bloc.dart @@ -2,9 +2,11 @@ import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:genshindb/domain/app_constants.dart'; import 'package:genshindb/domain/assets.dart'; import 'package:genshindb/domain/models/models.dart'; import 'package:genshindb/domain/services/genshin_service.dart'; +import 'package:tuple/tuple.dart'; part 'calculator_asc_materials_item_bloc.freezed.dart'; part 'calculator_asc_materials_item_event.dart'; @@ -17,6 +19,8 @@ class CalculatorAscMaterialsItemBloc extends Bloc state as _LoadedState; @@ -38,10 +42,15 @@ class CalculatorAscMaterialsItemBloc extends Bloc CharacterSkill.skill(name: e.title, currentLevel: minSkillLevel, desiredLevel: maxSkillLevel)).toList(), + currentLevel: itemAscensionLevelMap.entries.first.value, + desiredLevel: maxItemLevel, + currentAscensionLevel: minAscensionLevel, + desiredAscensionLevel: maxAscensionLevel, + skills: translation.skills + .map( + (e) => CharacterSkill.skill(name: e.title, currentLevel: minSkillLevel, desiredLevel: maxSkillLevel), + ) + .toList(), ); } final weapon = _genshinService.getWeapon(e.key); @@ -49,8 +58,10 @@ class CalculatorAscMaterialsItemBloc extends Bloc _levelChanged(e.newValue, currentState.desiredLevel), + desiredLevelChanged: (e) => _levelChanged(currentState.currentLevel, e.newValue), + currentAscensionLevelChanged: (e) => _ascensionChanged(e.newValue, currentState.desiredAscensionLevel), + desiredAscensionLevelChanged: (e) => _ascensionChanged(currentState.currentAscensionLevel, e.newValue), + skillCurrentLevelChanged: (e) => _skillChanged(e.index, e.newValue, true), + skillDesiredLevelChanged: (e) => _skillChanged(e.index, e.newValue, false), ); yield s; } - CalculatorAscMaterialsItemState _ascensionChanged(int currentLevel, int desiredLevel) { - var cl = currentLevel; - var dl = desiredLevel; + //TODO: COMPLETE THIS - if (cl > dl) { - dl = cl; - } else if (dl < cl) { - cl = dl; - } + CalculatorAscMaterialsItemState _levelChanged(int currentLevel, int desiredLevel) { + final tuple = _checkProvidedLevels(currentLevel, desiredLevel); + final cl = tuple.item1; + final dl = tuple.item2; + + return currentState.copyWith.call(currentLevel: currentLevel, desiredLevel: desiredLevel); + } + + CalculatorAscMaterialsItemState _ascensionChanged(int currentLevel, int desiredLevel) { + final tuple = _checkProvidedLevels(currentLevel, desiredLevel); + final cl = tuple.item1; + final dl = tuple.item2; //Here we consider the 0, because otherwise we will always start from a current level of 1, and sometimes, we want to know the whole thing //(from 1 to 10 with 1 inclusive) @@ -112,7 +126,7 @@ class CalculatorAscMaterialsItemBloc extends Bloc dl) { - dl = cl; - } else if (dl < cl) { - cl = dl; - } + final tuple = _checkProvidedLevels(currentChanged ? newValue : item.currentLevel, currentChanged ? item.desiredLevel : newValue); + final cl = tuple.item1; + final dl = tuple.item2; if (cl > maxSkillLevel || cl < minSkillLevel) { return currentState; @@ -147,4 +156,17 @@ class CalculatorAscMaterialsItemBloc extends Bloc _checkProvidedLevels(int currentLevel, int desiredLevel) { + var cl = currentLevel; + var dl = desiredLevel; + + if (cl > dl) { + dl = cl; + } else if (dl < cl) { + cl = dl; + } + + return Tuple2(cl, dl); + } } diff --git a/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_event.dart b/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_event.dart index 1a34b5656..38e6f053b 100644 --- a/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_event.dart +++ b/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_event.dart @@ -12,6 +12,8 @@ abstract class CalculatorAscMaterialsItemEvent with _$CalculatorAscMaterialsItem @required bool isCharacter, @required int currentLevel, @required int desiredLevel, + @required int currentAscensionLevel, + @required int desiredAscensionLevel, @required List skills, }) = _LoadWith; @@ -23,6 +25,14 @@ abstract class CalculatorAscMaterialsItemEvent with _$CalculatorAscMaterialsItem @required int newValue, }) = _DesiredLevelChanged; + const factory CalculatorAscMaterialsItemEvent.currentAscensionLevelChanged({ + @required int newValue, + }) = _CurrentAscensionLevelChanged; + + const factory CalculatorAscMaterialsItemEvent.desiredAscensionLevelChanged({ + @required int newValue, + }) = _DesiredAscensionLevelChanged; + const factory CalculatorAscMaterialsItemEvent.skillCurrentLevelChanged({ @required int index, @required int newValue, diff --git a/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_state.dart b/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_state.dart index 69e4a7c97..15d3ee779 100644 --- a/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_state.dart +++ b/lib/application/calculator_asc_materials_item/calculator_asc_materials_item_state.dart @@ -9,6 +9,8 @@ abstract class CalculatorAscMaterialsItemState with _$CalculatorAscMaterialsItem @required String imageFullPath, @required int currentLevel, @required int desiredLevel, + @required int currentAscensionLevel, + @required int desiredAscensionLevel, @Default([]) List skills, }) = _LoadedState; } diff --git a/lib/domain/app_constants.dart b/lib/domain/app_constants.dart index 718626959..fee02c982 100644 --- a/lib/domain/app_constants.dart +++ b/lib/domain/app_constants.dart @@ -5,8 +5,203 @@ import 'models/models.dart'; const artifactOrder = [4, 2, 5, 1, 3]; -final languagesMap = { +const languagesMap = { AppLanguageType.english: LanguageModel('en', 'US'), AppLanguageType.spanish: LanguageModel('es', 'ES'), // AppLanguageType.french: LanguageModel('fr', 'FR'), }; + +const itemAscensionLevelMap = { + 1: 20, + 2: 40, + 3: 50, + 4: 60, + 5: 70, + 6: 80, +}; + +const characterExp = [ + ItemExperience.forCharacters(1, 1000, 0), + ItemExperience.forCharacters(2, 1325, 1000), + ItemExperience.forCharacters(3, 1700, 2325), + ItemExperience.forCharacters(4, 2150, 4025), + ItemExperience.forCharacters(5, 2625, 6175), + ItemExperience.forCharacters(6, 3150, 8800), + ItemExperience.forCharacters(7, 3725, 11950), + ItemExperience.forCharacters(8, 4350, 15675), + ItemExperience.forCharacters(9, 5000, 20025), + ItemExperience.forCharacters(10, 5700, 25025), + ItemExperience.forCharacters(11, 6450, 30725), + ItemExperience.forCharacters(12, 7225, 37175), + ItemExperience.forCharacters(13, 8050, 44400), + ItemExperience.forCharacters(14, 8925, 52450), + ItemExperience.forCharacters(15, 9825, 61375), + ItemExperience.forCharacters(16, 10750, 71200), + ItemExperience.forCharacters(17, 11725, 81950), + ItemExperience.forCharacters(18, 12725, 93675), + ItemExperience.forCharacters(19, 13775, 106400), + ItemExperience.forCharacters(20, 14875, 120175), + ItemExperience.forCharacters(21, 16800, 135050), + ItemExperience.forCharacters(22, 18000, 151850), + ItemExperience.forCharacters(23, 19250, 169850), + ItemExperience.forCharacters(24, 20550, 189100), + ItemExperience.forCharacters(25, 21875, 209650), + ItemExperience.forCharacters(26, 23250, 231525), + ItemExperience.forCharacters(27, 24650, 254775), + ItemExperience.forCharacters(28, 26100, 279425), + ItemExperience.forCharacters(29, 27575, 305525), + ItemExperience.forCharacters(30, 29100, 333100), + ItemExperience.forCharacters(31, 30650, 362200), + ItemExperience.forCharacters(32, 32250, 392850), + ItemExperience.forCharacters(33, 33875, 425100), + ItemExperience.forCharacters(34, 35550, 458975), + ItemExperience.forCharacters(35, 37250, 494525), + ItemExperience.forCharacters(36, 38975, 531775), + ItemExperience.forCharacters(37, 40750, 570750), + ItemExperience.forCharacters(38, 42575, 611500), + ItemExperience.forCharacters(39, 44425, 654075), + ItemExperience.forCharacters(40, 46300, 698500), + ItemExperience.forCharacters(41, 50625, 744800), + ItemExperience.forCharacters(42, 52700, 795425), + ItemExperience.forCharacters(43, 54775, 848125), + ItemExperience.forCharacters(44, 56900, 902900), + ItemExperience.forCharacters(45, 59075, 959800), + ItemExperience.forCharacters(46, 61275, 1018875), + ItemExperience.forCharacters(47, 63525, 1080150), + ItemExperience.forCharacters(48, 65800, 1143675), + ItemExperience.forCharacters(49, 68125, 1209475), + ItemExperience.forCharacters(50, 70475, 1277600), + ItemExperience.forCharacters(51, 76500, 1348075), + ItemExperience.forCharacters(52, 79050, 1424575), + ItemExperience.forCharacters(53, 81650, 1503625), + ItemExperience.forCharacters(54, 84275, 1585275), + ItemExperience.forCharacters(55, 86950, 1669550), + ItemExperience.forCharacters(56, 89650, 1756500), + ItemExperience.forCharacters(57, 92400, 1846150), + ItemExperience.forCharacters(58, 95175, 1938550), + ItemExperience.forCharacters(59, 98000, 2033725), + ItemExperience.forCharacters(60, 100875, 2131725), + ItemExperience.forCharacters(61, 108950, 2232600), + ItemExperience.forCharacters(62, 112050, 2341550), + ItemExperience.forCharacters(63, 115175, 2453600), + ItemExperience.forCharacters(64, 118325, 2568775), + ItemExperience.forCharacters(65, 121525, 2687100), + ItemExperience.forCharacters(66, 124775, 2808625), + ItemExperience.forCharacters(67, 128075, 2933400), + ItemExperience.forCharacters(68, 131400, 3061475), + ItemExperience.forCharacters(69, 134775, 3192875), + ItemExperience.forCharacters(70, 138175, 3327650), + ItemExperience.forCharacters(71, 148700, 3465825), + ItemExperience.forCharacters(72, 152375, 3614525), + ItemExperience.forCharacters(73, 156075, 3766900), + ItemExperience.forCharacters(74, 159825, 3922975), + ItemExperience.forCharacters(75, 163600, 4082800), + ItemExperience.forCharacters(76, 167425, 4246400), + ItemExperience.forCharacters(77, 171300, 4413825), + ItemExperience.forCharacters(78, 175225, 4585125), + ItemExperience.forCharacters(79, 179175, 4760350), + ItemExperience.forCharacters(80, 183175, 4939525), + ItemExperience.forCharacters(81, 216225, 5122700), + ItemExperience.forCharacters(82, 243025, 5338925), + ItemExperience.forCharacters(83, 273100, 5581950), + ItemExperience.forCharacters(84, 306800, 5855050), + ItemExperience.forCharacters(85, 344600, 6161850), + ItemExperience.forCharacters(86, 386950, 6506450), + ItemExperience.forCharacters(87, 434425, 6893400), + ItemExperience.forCharacters(88, 487625, 7327825), + ItemExperience.forCharacters(89, 547200, 7815450), + ItemExperience.forCharacters(90, -1, 8362650), +]; + +const weaponExp = [ + ItemExperience.forWeapons(1, 600, 0), + ItemExperience.forWeapons(2, 950, 600), + ItemExperience.forWeapons(3, 1350, 1550), + ItemExperience.forWeapons(4, 1800, 2900), + ItemExperience.forWeapons(5, 2325, 4700), + ItemExperience.forWeapons(6, 2925, 7025), + ItemExperience.forWeapons(7, 3525, 9950), + ItemExperience.forWeapons(8, 4200, 13475), + ItemExperience.forWeapons(9, 4950, 17675), + ItemExperience.forWeapons(10, 5700, 22625), + ItemExperience.forWeapons(11, 6525, 28325), + ItemExperience.forWeapons(12, 7400, 34850), + ItemExperience.forWeapons(13, 8300, 42250), + ItemExperience.forWeapons(14, 9225, 50550), + ItemExperience.forWeapons(15, 10200, 59775), + ItemExperience.forWeapons(16, 11250, 69975), + ItemExperience.forWeapons(17, 12300, 81225), + ItemExperience.forWeapons(18, 13425, 93525), + ItemExperience.forWeapons(19, 14600, 106950), + ItemExperience.forWeapons(20, 15750, 121550), + ItemExperience.forWeapons(21, 17850, 137300), + ItemExperience.forWeapons(22, 19175, 155150), + ItemExperience.forWeapons(23, 20550, 174325), + ItemExperience.forWeapons(24, 21975, 194875), + ItemExperience.forWeapons(25, 23450, 216850), + ItemExperience.forWeapons(26, 24950, 240300), + ItemExperience.forWeapons(27, 26475, 265250), + ItemExperience.forWeapons(28, 28050, 291725), + ItemExperience.forWeapons(29, 29675, 319775), + ItemExperience.forWeapons(30, 31350, 349450), + ItemExperience.forWeapons(31, 33050, 380800), + ItemExperience.forWeapons(32, 34800, 413850), + ItemExperience.forWeapons(33, 36575, 448650), + ItemExperience.forWeapons(34, 38400, 485225), + ItemExperience.forWeapons(35, 40250, 523625), + ItemExperience.forWeapons(36, 42150, 563875), + ItemExperience.forWeapons(37, 44100, 606025), + ItemExperience.forWeapons(38, 46100, 650125), + ItemExperience.forWeapons(39, 48125, 696225), + ItemExperience.forWeapons(40, 50150, 744350), + ItemExperience.forWeapons(41, 54875, 794500), + ItemExperience.forWeapons(42, 57125, 849375), + ItemExperience.forWeapons(43, 59400, 906500), + ItemExperience.forWeapons(44, 61725, 965900), + ItemExperience.forWeapons(45, 64100, 1027625), + ItemExperience.forWeapons(46, 66500, 1091725), + ItemExperience.forWeapons(47, 68925, 1158225), + ItemExperience.forWeapons(48, 71400, 1227150), + ItemExperience.forWeapons(49, 73950, 1298550), + ItemExperience.forWeapons(50, 76500, 1372500), + ItemExperience.forWeapons(51, 83075, 1449000), + ItemExperience.forWeapons(52, 85850, 1532075), + ItemExperience.forWeapons(53, 88650, 1617925), + ItemExperience.forWeapons(54, 91550, 1706575), + ItemExperience.forWeapons(55, 94425, 1798125), + ItemExperience.forWeapons(56, 97400, 1892550), + ItemExperience.forWeapons(57, 100350, 1989950), + ItemExperience.forWeapons(58, 103400, 2090300), + ItemExperience.forWeapons(59, 106475, 2193700), + ItemExperience.forWeapons(60, 109575, 2300175), + ItemExperience.forWeapons(61, 118350, 2409750), + ItemExperience.forWeapons(62, 121700, 2528100), + ItemExperience.forWeapons(63, 125100, 2649800), + ItemExperience.forWeapons(64, 128550, 2774900), + ItemExperience.forWeapons(65, 132050, 2903450), + ItemExperience.forWeapons(66, 135575, 3035500), + ItemExperience.forWeapons(67, 139125, 3171075), + ItemExperience.forWeapons(68, 142725, 3310200), + ItemExperience.forWeapons(69, 146375, 3452925), + ItemExperience.forWeapons(70, 150075, 3599300), + ItemExperience.forWeapons(71, 161525, 3749375), + ItemExperience.forWeapons(72, 165500, 3910900), + ItemExperience.forWeapons(73, 169500, 4076400), + ItemExperience.forWeapons(74, 173550, 4245900), + ItemExperience.forWeapons(75, 177650, 4419450), + ItemExperience.forWeapons(76, 181800, 4597100), + ItemExperience.forWeapons(77, 186000, 4778900), + ItemExperience.forWeapons(78, 190250, 4964900), + ItemExperience.forWeapons(79, 194525, 5155150), + ItemExperience.forWeapons(80, 198875, 5349675), + ItemExperience.forWeapons(81, 234725, 5548550), + ItemExperience.forWeapons(82, 263825, 5783275), + ItemExperience.forWeapons(83, 296400, 6047100), + ItemExperience.forWeapons(84, 332975, 6343500), + ItemExperience.forWeapons(85, 373950, 6676475), + ItemExperience.forWeapons(86, 419925, 7050425), + ItemExperience.forWeapons(87, 471375, 7470350), + ItemExperience.forWeapons(88, 529050, 7941725), + ItemExperience.forWeapons(89, 593675, 8470775), + ItemExperience.forWeapons(90, -1, 9064450), +]; diff --git a/lib/domain/enums/material_type.dart b/lib/domain/enums/material_type.dart index b5118f81f..eebe39fac 100644 --- a/lib/domain/enums/material_type.dart +++ b/lib/domain/enums/material_type.dart @@ -9,4 +9,6 @@ enum MaterialType { currency, others, ingredient, + expWeapon, + expCharacter, } diff --git a/lib/domain/models/calculator_asc_materials/item_ascension_materials.dart b/lib/domain/models/calculator_asc_materials/item_ascension_materials.dart index e173482a6..420a498b1 100644 --- a/lib/domain/models/calculator_asc_materials/item_ascension_materials.dart +++ b/lib/domain/models/calculator_asc_materials/item_ascension_materials.dart @@ -7,26 +7,32 @@ part 'item_ascension_materials.freezed.dart'; @freezed abstract class ItemAscensionMaterials with _$ItemAscensionMaterials { - const factory ItemAscensionMaterials.forCharacters( - {@required String key, - @required String name, - @required String image, - @required int rarity, - @required List materials, - @required int currentLevel, - @required int desiredLevel, - @required List skills, - @Default(true) bool isCharacter}) = _ForCharacter; + const factory ItemAscensionMaterials.forCharacters({ + @required String key, + @required String name, + @required String image, + @required int rarity, + @required List materials, + @required int currentLevel, + @required int desiredLevel, + @required int currentAscensionLevel, + @required int desiredAscensionLevel, + @required List skills, + @Default(true) bool isCharacter, + }) = _ForCharacter; - const factory ItemAscensionMaterials.forWeapons( - {@required String key, - @required String name, - @required String image, - @required int rarity, - @required List materials, - @required int currentLevel, - @required int desiredLevel, - //This are here just for convenience - @Default([]) List skills, - @Default(false) bool isCharacter}) = _ForWeapon; + const factory ItemAscensionMaterials.forWeapons({ + @required String key, + @required String name, + @required String image, + @required int rarity, + @required List materials, + @required int currentLevel, + @required int desiredLevel, + @required int currentAscensionLevel, + @required int desiredAscensionLevel, + //This are here just for convenience + @Default([]) List skills, + @Default(false) bool isCharacter, + }) = _ForWeapon; } diff --git a/lib/domain/models/items/item_experience.dart b/lib/domain/models/items/item_experience.dart new file mode 100644 index 000000000..a15e2c58b --- /dev/null +++ b/lib/domain/models/items/item_experience.dart @@ -0,0 +1,20 @@ +class ItemExperience { + final int level; + final int nextLevelExp; + final int totalExp; + final bool isForCharacter; + + bool get maxReached => level == -1; + + const ItemExperience.forCharacters( + this.level, + this.nextLevelExp, + this.totalExp, + ) : isForCharacter = true; + + const ItemExperience.forWeapons( + this.level, + this.nextLevelExp, + this.totalExp, + ) : isForCharacter = false; +} diff --git a/lib/domain/models/language_model.dart b/lib/domain/models/language_model.dart index 2f2b5dd2d..7946b3c42 100644 --- a/lib/domain/models/language_model.dart +++ b/lib/domain/models/language_model.dart @@ -2,7 +2,7 @@ class LanguageModel { final String code; final String countryCode; - LanguageModel(this.code, this.countryCode) + const LanguageModel(this.code, this.countryCode) : assert(code != null), assert(countryCode != null); } diff --git a/lib/domain/models/models.dart b/lib/domain/models/models.dart index 3c49336a1..5ad072f3a 100644 --- a/lib/domain/models/models.dart +++ b/lib/domain/models/models.dart @@ -31,6 +31,7 @@ export 'elements/element_reaction_card_model.dart'; export 'home/today_char_ascension_materials_model.dart'; export 'home/today_weapon_ascension_material_model.dart'; export 'items/item_ascension_material_model.dart'; +export 'items/item_experience.dart'; export 'language_model.dart'; export 'settings/app_settings.dart'; export 'tierlist/tierlist_row_model.dart'; diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 3babee88a..c6ac6c00c 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -37,31 +37,35 @@ class MessageLookup extends MessageLookupByLibrary { static m8(value) => "${value} CRIT Rate %"; - static m9(value) => "${value} DEF"; + static m9(value) => "Current: ${value}"; - static m10(value) => "${value} DEF %"; + static m10(value) => "${value} DEF"; - static m11(value) => "${value} Elementary Mastery"; + static m11(value) => "${value} DEF %"; - static m12(value) => "${value} Energy Recharge %"; + static m12(value) => "Desired: ${value}"; - static m13(value) => "${value} Healing Bonus %"; + static m13(value) => "${value} Elementary Mastery"; - static m14(value) => "${value} HP"; + static m14(value) => "${value} Energy Recharge %"; - static m15(value) => "${value} HP %"; + static m15(value) => "${value} Healing Bonus %"; - static m16(value) => "${value} PHYS DMG Bonus"; + static m16(value) => "${value} HP"; - static m17(value) => "${value} PHYS DMG %"; + static m17(value) => "${value} HP %"; - static m18(value) => "Talent Ascension ${value}"; + static m18(value) => "${value} PHYS DMG Bonus"; - static m19(value) => "Unlocked at ascension level ${value}"; + static m19(value) => "${value} PHYS DMG %"; - static m20(value, x) => "${value} ${x} DMG Bonus %"; + static m20(value) => "Talent Ascension ${value}"; - static m21(value) => "${value} Piece(s)"; + static m21(value) => "Unlocked at ascension level ${value}"; + + static m22(value, x) => "${value} ${x} DMG Bonus %"; + + static m23(value) => "${value} Piece(s)"; final messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { @@ -104,6 +108,7 @@ class MessageLookup extends MessageLookupByLibrary { "characters" : MessageLookupByLibrary.simpleMessage("Characters"), "chargedAttack" : MessageLookupByLibrary.simpleMessage("Charged Attack"), "chest" : MessageLookupByLibrary.simpleMessage("Chest"), + "chooseALevel" : MessageLookupByLibrary.simpleMessage("Choose a level"), "chooseAccentColor" : MessageLookupByLibrary.simpleMessage("Choose an accent color"), "chooseBaseAppTheme" : MessageLookupByLibrary.simpleMessage("Choose base app theme"), "chooseLanguage" : MessageLookupByLibrary.simpleMessage("Choose a language"), @@ -126,16 +131,20 @@ class MessageLookup extends MessageLookupByLibrary { "crown" : MessageLookupByLibrary.simpleMessage("Crown"), "cryo" : MessageLookupByLibrary.simpleMessage("Cryo"), "currency" : MessageLookupByLibrary.simpleMessage("Currency"), + "currentAscension" : MessageLookupByLibrary.simpleMessage("Current Ascension"), "currentLevel" : MessageLookupByLibrary.simpleMessage("Current level"), + "currentX" : m9, "dark" : MessageLookupByLibrary.simpleMessage("Dark"), "day" : MessageLookupByLibrary.simpleMessage("Day"), - "def" : m9, - "defPercentage" : m10, + "def" : m10, + "defPercentage" : m11, "deleteRow" : MessageLookupByLibrary.simpleMessage("Delete row"), "dendro" : MessageLookupByLibrary.simpleMessage("Dendro"), "desc" : MessageLookupByLibrary.simpleMessage("Descending"), "description" : MessageLookupByLibrary.simpleMessage("Description"), + "desiredAscension" : MessageLookupByLibrary.simpleMessage("Desired Ascension"), "desiredLevel" : MessageLookupByLibrary.simpleMessage("Desired level"), + "desiredX" : m12, "disclaimer" : MessageLookupByLibrary.simpleMessage("Disclaimer"), "disclaimerMsg" : MessageLookupByLibrary.simpleMessage("This app is not affiliated with or endorsed by miHoYo. GenshinDb is just a database app for the Genshin Impact game"), "dps" : MessageLookupByLibrary.simpleMessage("DPS"), @@ -151,9 +160,9 @@ class MessageLookup extends MessageLookupByLibrary { "elementalResonances" : MessageLookupByLibrary.simpleMessage("Elemental Resonances"), "elementalResonancesExplained" : MessageLookupByLibrary.simpleMessage("Having these types of character in your party will give you the corresponding effect"), "elementalSkill" : MessageLookupByLibrary.simpleMessage("Elemental Skill"), - "elementaryMastery" : m11, + "elementaryMastery" : m13, "elements" : MessageLookupByLibrary.simpleMessage("Elements"), - "energyRechargePercentage" : m12, + "energyRechargePercentage" : m14, "english" : MessageLookupByLibrary.simpleMessage("English"), "europe" : MessageLookupByLibrary.simpleMessage("Europe"), "female" : MessageLookupByLibrary.simpleMessage("Female"), @@ -170,11 +179,11 @@ class MessageLookup extends MessageLookupByLibrary { "goblet" : MessageLookupByLibrary.simpleMessage("Goblet"), "happyBirthday" : MessageLookupByLibrary.simpleMessage("Happy Birthday!"), "healingBonus" : MessageLookupByLibrary.simpleMessage("Healing Bonus"), - "healingBonusPercentage" : m13, + "healingBonusPercentage" : m15, "hold" : MessageLookupByLibrary.simpleMessage("Hold"), "home" : MessageLookupByLibrary.simpleMessage("Home"), - "hp" : m14, - "hpPercentage" : m15, + "hp" : m16, + "hpPercentage" : m17, "hydro" : MessageLookupByLibrary.simpleMessage("Hydro"), "imgSavedSuccessfully" : MessageLookupByLibrary.simpleMessage("Image was successfully saved to the gallery"), "issues" : MessageLookupByLibrary.simpleMessage("Issues"), @@ -205,8 +214,8 @@ class MessageLookup extends MessageLookupByLibrary { "others" : MessageLookupByLibrary.simpleMessage("Others"), "partial" : MessageLookupByLibrary.simpleMessage("Partial"), "passives" : MessageLookupByLibrary.simpleMessage("Passives"), - "physDmgBonus" : m16, - "physDmgPercentage" : m17, + "physDmgBonus" : m18, + "physDmgPercentage" : m19, "pickColor" : MessageLookupByLibrary.simpleMessage("Pick a color"), "pieces" : MessageLookupByLibrary.simpleMessage("Pieces"), "plume" : MessageLookupByLibrary.simpleMessage("Plume"), @@ -258,7 +267,7 @@ class MessageLookup extends MessageLookupByLibrary { "supportDps" : MessageLookupByLibrary.simpleMessage("Support DPS"), "supportMsg" : MessageLookupByLibrary.simpleMessage("I made this app in my free time and it is also open source. If you would like to help me, report an issue, have an idea, want a feature to be implemented, etc, please open an issue in my Github:"), "sword" : MessageLookupByLibrary.simpleMessage("Sword"), - "talentAscensionX" : m18, + "talentAscensionX" : m20, "talentsAscension" : MessageLookupByLibrary.simpleMessage("Talents Ascension"), "theme" : MessageLookupByLibrary.simpleMessage("Theme"), "thursday" : MessageLookupByLibrary.simpleMessage("Thursday"), @@ -269,7 +278,7 @@ class MessageLookup extends MessageLookupByLibrary { "tuesday" : MessageLookupByLibrary.simpleMessage("Tuesday"), "type" : MessageLookupByLibrary.simpleMessage("Type"), "unknownError" : MessageLookupByLibrary.simpleMessage("Unknown error occurred"), - "unlockedAtAscensionLevelX" : m19, + "unlockedAtAscensionLevelX" : m21, "unlockedAutomatically" : MessageLookupByLibrary.simpleMessage("Unlocked Automatically"), "unreleased" : MessageLookupByLibrary.simpleMessage("Unreleased"), "utility" : MessageLookupByLibrary.simpleMessage("Utility"), @@ -278,8 +287,8 @@ class MessageLookup extends MessageLookupByLibrary { "weapons" : MessageLookupByLibrary.simpleMessage("Weapons"), "wednesday" : MessageLookupByLibrary.simpleMessage("Wednesday"), "wishSimulator" : MessageLookupByLibrary.simpleMessage("Wish simulator"), - "xDmgBonusPercentage" : m20, - "xPieces" : m21, + "xDmgBonusPercentage" : m22, + "xPieces" : m23, "youCanAlsoSendMeAnEmail" : MessageLookupByLibrary.simpleMessage("You can also send me an email") }; } diff --git a/lib/generated/intl/messages_es_ES.dart b/lib/generated/intl/messages_es_ES.dart index 6befb07f3..2b5993909 100644 --- a/lib/generated/intl/messages_es_ES.dart +++ b/lib/generated/intl/messages_es_ES.dart @@ -37,31 +37,35 @@ class MessageLookup extends MessageLookupByLibrary { static m8(value) => "${value} Prob. CRIT %"; - static m9(value) => "${value} DEF"; + static m9(value) => "Actual: ${value}"; - static m10(value) => "${value} DEF %"; + static m10(value) => "${value} DEF"; - static m11(value) => "${value} Maestría Elemental"; + static m11(value) => "${value} DEF %"; - static m12(value) => "${value} Recarga de Energía %"; + static m12(value) => "Deseado: ${value}"; - static m13(value) => "${value} Bonus de Curación %"; + static m13(value) => "${value} Maestría Elemental"; - static m14(value) => "${value} Vida"; + static m14(value) => "${value} Recarga de Energía %"; - static m15(value) => "${value} Vida %"; + static m15(value) => "${value} Bonus de Curación %"; - static m16(value) => "${value} Bono Daño FIS."; + static m16(value) => "${value} Vida"; - static m17(value) => "${value} Daño FIS. %"; + static m17(value) => "${value} Vida %"; - static m18(value) => "Talento de Ascención ${value}"; + static m18(value) => "${value} Bono Daño FIS."; - static m19(value) => "Desbloqueada en nivel de ascención ${value}"; + static m19(value) => "${value} Daño FIS. %"; - static m20(value, x) => "${value} Bono de Daño ${x} %"; + static m20(value) => "Talento de Ascención ${value}"; - static m21(value) => "${value} Pieza(s)"; + static m21(value) => "Desbloqueada en nivel de ascención ${value}"; + + static m22(value, x) => "${value} Bono de Daño ${x} %"; + + static m23(value) => "${value} Pieza(s)"; final messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { @@ -104,6 +108,7 @@ class MessageLookup extends MessageLookupByLibrary { "characters" : MessageLookupByLibrary.simpleMessage("Personajes"), "chargedAttack" : MessageLookupByLibrary.simpleMessage("Ataque Cargado"), "chest" : MessageLookupByLibrary.simpleMessage("Cofre"), + "chooseALevel" : MessageLookupByLibrary.simpleMessage("Escoge un nivel"), "chooseAccentColor" : MessageLookupByLibrary.simpleMessage("Escoge un color de acento"), "chooseBaseAppTheme" : MessageLookupByLibrary.simpleMessage("Escoge un tema base"), "chooseLanguage" : MessageLookupByLibrary.simpleMessage("Escoge un lenguaje"), @@ -125,16 +130,20 @@ class MessageLookup extends MessageLookupByLibrary { "crown" : MessageLookupByLibrary.simpleMessage("Corona"), "cryo" : MessageLookupByLibrary.simpleMessage("Cryo"), "currency" : MessageLookupByLibrary.simpleMessage("Moneda"), + "currentAscension" : MessageLookupByLibrary.simpleMessage("Ascensión Actual"), "currentLevel" : MessageLookupByLibrary.simpleMessage("Nivel actual"), + "currentX" : m9, "dark" : MessageLookupByLibrary.simpleMessage("Oscuro"), "day" : MessageLookupByLibrary.simpleMessage("Día"), - "def" : m9, - "defPercentage" : m10, + "def" : m10, + "defPercentage" : m11, "deleteRow" : MessageLookupByLibrary.simpleMessage("Borrar fila"), "dendro" : MessageLookupByLibrary.simpleMessage("Dendro"), "desc" : MessageLookupByLibrary.simpleMessage("Descendente"), "description" : MessageLookupByLibrary.simpleMessage("Descripción"), + "desiredAscension" : MessageLookupByLibrary.simpleMessage("Ascención Deseada"), "desiredLevel" : MessageLookupByLibrary.simpleMessage("Nivel deseado"), + "desiredX" : m12, "disclaimer" : MessageLookupByLibrary.simpleMessage("Disclaimer"), "disclaimerMsg" : MessageLookupByLibrary.simpleMessage("Esta app no está afiliada ni asociada a miHoYo. GenshinDb es solo una aplicación de tipo base de datos para el juego Genshin Impact"), "dps" : MessageLookupByLibrary.simpleMessage("DPS"), @@ -150,9 +159,9 @@ class MessageLookup extends MessageLookupByLibrary { "elementalResonances" : MessageLookupByLibrary.simpleMessage("Resonancias Elementales"), "elementalResonancesExplained" : MessageLookupByLibrary.simpleMessage("Teniendo estos tipos de personajes en tu equipo te daran el effecto correspondiente"), "elementalSkill" : MessageLookupByLibrary.simpleMessage("Habilidad Elemental"), - "elementaryMastery" : m11, + "elementaryMastery" : m13, "elements" : MessageLookupByLibrary.simpleMessage("Elementos"), - "energyRechargePercentage" : m12, + "energyRechargePercentage" : m14, "english" : MessageLookupByLibrary.simpleMessage("Inglés"), "europe" : MessageLookupByLibrary.simpleMessage("Europa"), "female" : MessageLookupByLibrary.simpleMessage("Mujer"), @@ -169,11 +178,11 @@ class MessageLookup extends MessageLookupByLibrary { "goblet" : MessageLookupByLibrary.simpleMessage("Copa"), "happyBirthday" : MessageLookupByLibrary.simpleMessage("¡Feliz Cumpleaños!"), "healingBonus" : MessageLookupByLibrary.simpleMessage("Bono de curación"), - "healingBonusPercentage" : m13, + "healingBonusPercentage" : m15, "hold" : MessageLookupByLibrary.simpleMessage("Mantener"), "home" : MessageLookupByLibrary.simpleMessage("Inicio"), - "hp" : m14, - "hpPercentage" : m15, + "hp" : m16, + "hpPercentage" : m17, "hydro" : MessageLookupByLibrary.simpleMessage("Hydro"), "imgSavedSuccessfully" : MessageLookupByLibrary.simpleMessage("La imagen fue guardada exitósamente en la galería"), "issues" : MessageLookupByLibrary.simpleMessage("Inconvenientes"), @@ -204,8 +213,8 @@ class MessageLookup extends MessageLookupByLibrary { "others" : MessageLookupByLibrary.simpleMessage("Otros"), "partial" : MessageLookupByLibrary.simpleMessage("Parcial"), "passives" : MessageLookupByLibrary.simpleMessage("Pasivas"), - "physDmgBonus" : m16, - "physDmgPercentage" : m17, + "physDmgBonus" : m18, + "physDmgPercentage" : m19, "pickColor" : MessageLookupByLibrary.simpleMessage("Selecciona un color"), "pieces" : MessageLookupByLibrary.simpleMessage("Piezas"), "plume" : MessageLookupByLibrary.simpleMessage("Pluma"), @@ -257,7 +266,7 @@ class MessageLookup extends MessageLookupByLibrary { "supportDps" : MessageLookupByLibrary.simpleMessage("DPS de Soporte"), "supportMsg" : MessageLookupByLibrary.simpleMessage("Hice esta aplicación en mi tiempo libre y también es de código abierto. Si deseas ayudarme, informar de un problema, tienes una idea, deseas que se implemente una funcionalidad, etc., crea un issue en mi Github:"), "sword" : MessageLookupByLibrary.simpleMessage("Espada"), - "talentAscensionX" : m18, + "talentAscensionX" : m20, "talentsAscension" : MessageLookupByLibrary.simpleMessage("Talentos de Ascención"), "theme" : MessageLookupByLibrary.simpleMessage("Tema"), "thursday" : MessageLookupByLibrary.simpleMessage("Jueves"), @@ -268,7 +277,7 @@ class MessageLookup extends MessageLookupByLibrary { "tuesday" : MessageLookupByLibrary.simpleMessage("Martes"), "type" : MessageLookupByLibrary.simpleMessage("Tipo"), "unknownError" : MessageLookupByLibrary.simpleMessage("Un error desconocido ha ocurrido"), - "unlockedAtAscensionLevelX" : m19, + "unlockedAtAscensionLevelX" : m21, "unlockedAutomatically" : MessageLookupByLibrary.simpleMessage("Desbloqueada Automáticamente"), "unreleased" : MessageLookupByLibrary.simpleMessage("No Publicado"), "utility" : MessageLookupByLibrary.simpleMessage("Utilidad"), @@ -277,8 +286,8 @@ class MessageLookup extends MessageLookupByLibrary { "weapons" : MessageLookupByLibrary.simpleMessage("Armas"), "wednesday" : MessageLookupByLibrary.simpleMessage("Miércoles"), "wishSimulator" : MessageLookupByLibrary.simpleMessage("Simulador de Deseos"), - "xDmgBonusPercentage" : m20, - "xPieces" : m21, + "xDmgBonusPercentage" : m22, + "xPieces" : m23, "youCanAlsoSendMeAnEmail" : MessageLookupByLibrary.simpleMessage("También puedes enviarme un correo") }; } diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index cf01b41d3..f3ca9285d 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -2194,6 +2194,56 @@ class S { args: [], ); } + + /// `Current: {value}` + String currentX(Object value) { + return Intl.message( + 'Current: $value', + name: 'currentX', + desc: '', + args: [value], + ); + } + + /// `Desired: {value}` + String desiredX(Object value) { + return Intl.message( + 'Desired: $value', + name: 'desiredX', + desc: '', + args: [value], + ); + } + + /// `Current Ascension` + String get currentAscension { + return Intl.message( + 'Current Ascension', + name: 'currentAscension', + desc: '', + args: [], + ); + } + + /// `Desired Ascension` + String get desiredAscension { + return Intl.message( + 'Desired Ascension', + name: 'desiredAscension', + desc: '', + args: [], + ); + } + + /// `Choose a level` + String get chooseALevel { + return Intl.message( + 'Choose a level', + name: 'chooseALevel', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 076cfa80d..63965d81e 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -214,5 +214,10 @@ "geo": "Geo", "pyro": "Pyro", "hydro": "Hydro", - "craftingMaterials": "Crafting Materials" + "craftingMaterials": "Crafting Materials", + "currentX": "Current: {value}", + "desiredX": "Desired: {value}", + "currentAscension": "Current Ascension", + "desiredAscension": "Desired Ascension", + "chooseALevel": "Choose a level" } \ No newline at end of file diff --git a/lib/l10n/intl_es_ES.arb b/lib/l10n/intl_es_ES.arb index efb553be4..5cb04e2d5 100644 --- a/lib/l10n/intl_es_ES.arb +++ b/lib/l10n/intl_es_ES.arb @@ -213,5 +213,10 @@ "geo": "Geo", "pyro": "Pyro", "hydro": "Hydro", - "craftingMaterials": "Materiales de Elaboración" + "craftingMaterials": "Materiales de Elaboración", + "currentX": "Actual: {value}", + "desiredX": "Deseado: {value}", + "currentAscension": "Ascensión Actual", + "desiredAscension": "Ascención Deseada", + "chooseALevel": "Escoge un nivel" } \ No newline at end of file diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index 7cd65ae0a..38af69234 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -214,5 +214,10 @@ "geo": "Geo", "pyro": "Pyro", "hydro": "Hydro", - "craftingMaterials": "Crafting Materials" + "craftingMaterials": "Crafting Materials", + "currentX": "Current: {value}", + "desiredX": "Desired: {value}", + "currentAscension": "Current Ascension", + "desiredAscension": "Desired Ascension", + "chooseALevel": "Choose a level" } \ No newline at end of file diff --git a/lib/presentation/calculator_asc_materials/widgets/add_edit_item_bottom_sheet.dart b/lib/presentation/calculator_asc_materials/widgets/add_edit_item_bottom_sheet.dart index 1df09fe7a..0dc8bf3b2 100644 --- a/lib/presentation/calculator_asc_materials/widgets/add_edit_item_bottom_sheet.dart +++ b/lib/presentation/calculator_asc_materials/widgets/add_edit_item_bottom_sheet.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:genshindb/application/bloc.dart'; -import 'package:genshindb/domain/assets.dart'; import 'package:genshindb/domain/extensions/iterable_extensions.dart'; import 'package:genshindb/domain/models/models.dart'; import 'package:genshindb/generated/l10n.dart'; import 'package:genshindb/presentation/shared/common_bottom_sheet.dart'; import 'package:genshindb/presentation/shared/loading.dart'; +import 'package:numberpicker/numberpicker.dart'; +import 'ascension_level.dart'; import 'skill_item.dart'; class AddEditItemBottomSheet extends StatelessWidget { @@ -44,20 +45,38 @@ class AddEditItemBottomSheet extends StatelessWidget { titleIcon: !isInEditMode ? Icons.add : Icons.edit, iconSize: 40, onOk: () => isAWeapon - ? _applyChangesForWeapon(state.currentLevel, state.desiredLevel, context) - : _applyChangesForCharacter(state.currentLevel, state.desiredLevel, state.skills, context), + ? _applyChangesForWeapon(state.currentLevel, state.desiredLevel, state.currentAscensionLevel, state.desiredAscensionLevel, context) + : _applyChangesForCharacter( + state.currentLevel, + state.desiredLevel, + state.currentAscensionLevel, + state.desiredAscensionLevel, + state.skills, + context, + ), onCancel: () => Navigator.of(context).pop(), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text(s.currentLevel, textAlign: TextAlign.center, style: theme.textTheme.subtitle2), - AscensionLevel(isCurrentLevel: true, level: state.currentLevel), - Container( - margin: const EdgeInsets.only(top: 10), - child: Text(s.desiredLevel, textAlign: TextAlign.center, style: theme.textTheme.subtitle2), + Text(s.level, textAlign: TextAlign.center, style: theme.textTheme.subtitle2.copyWith(fontWeight: FontWeight.bold)), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + OutlineButton( + onPressed: () => _showLevelPickerDialog(context, state.currentLevel, true), + child: Text(s.currentX(state.currentLevel)), + ), + OutlineButton( + onPressed: () => _showLevelPickerDialog(context, state.desiredLevel, false), + child: Text(s.desiredX(state.desiredLevel)), + ), + ], ), - AscensionLevel(isCurrentLevel: false, level: state.desiredLevel), + Text(s.currentAscension, textAlign: TextAlign.center, style: theme.textTheme.subtitle2), + AscensionLevel(isCurrentLevel: true, level: state.currentAscensionLevel), + Text(s.desiredAscension, textAlign: TextAlign.center, style: theme.textTheme.subtitle2), + AscensionLevel(isCurrentLevel: false, level: state.desiredAscensionLevel), ...state.skills .mapIndex((e, index) => SkillItem( index: index, @@ -73,80 +92,86 @@ class AddEditItemBottomSheet extends StatelessWidget { ); } + Future _showLevelPickerDialog(BuildContext context, int value, bool forCurrentLevel) async { + final theme = Theme.of(context); + final s = S.of(context); + final newValue = await showDialog( + context: context, + builder: (BuildContext context) { + return NumberPickerDialog.integer( + minValue: 0, + maxValue: 90, + title: Text(s.chooseALevel), + initialIntegerValue: value, + infiniteLoop: true, + cancelWidget: Text(s.cancel), + confirmWidget: Text(s.ok, style: TextStyle(color: theme.primaryColor)), + ); + }, + ); + + if (newValue == null) { + return; + } + + final event = forCurrentLevel + ? CalculatorAscMaterialsItemEvent.currentLevelChanged(newValue: newValue) + : CalculatorAscMaterialsItemEvent.desiredLevelChanged(newValue: newValue); + context.read().add(event); + } + void _applyChangesForWeapon( int currentLevel, int desiredLevel, + int currentAscensionLevel, + int desiredAscensionLevel, BuildContext context, ) { - if (!isInEditMode) { - context - .read() - .add(CalculatorAscMaterialsEvent.addWeapon(key: keyName, currentLevel: currentLevel, desiredLevel: desiredLevel)); - } else { - context - .read() - .add(CalculatorAscMaterialsEvent.updateWeapon(index: index, currentLevel: currentLevel, desiredLevel: desiredLevel)); - } + final event = !isInEditMode + ? CalculatorAscMaterialsEvent.addWeapon( + key: keyName, + currentLevel: currentLevel, + desiredLevel: desiredLevel, + currentAscensionLevel: currentAscensionLevel, + desiredAscensionLevel: desiredAscensionLevel, + ) + : CalculatorAscMaterialsEvent.updateWeapon( + index: index, + currentLevel: currentLevel, + desiredLevel: desiredLevel, + currentAscensionLevel: currentAscensionLevel, + desiredAscensionLevel: desiredAscensionLevel, + ); + context.read().add(event); Navigator.of(context).pop(); } void _applyChangesForCharacter( int currentLevel, int desiredLevel, + int currentAscensionLevel, + int desiredAscensionLevel, List skills, BuildContext context, ) { - if (!isInEditMode) { - context - .read() - .add(CalculatorAscMaterialsEvent.addCharacter(key: keyName, currentLevel: currentLevel, desiredLevel: desiredLevel, skills: skills)); - } else { - context - .read() - .add(CalculatorAscMaterialsEvent.updateCharacter(index: index, currentLevel: currentLevel, desiredLevel: desiredLevel, skills: skills)); - } + final event = !isInEditMode + ? CalculatorAscMaterialsEvent.addCharacter( + key: keyName, + currentLevel: currentLevel, + desiredLevel: desiredLevel, + skills: skills, + currentAscensionLevel: currentAscensionLevel, + desiredAscensionLevel: desiredAscensionLevel, + ) + : CalculatorAscMaterialsEvent.updateCharacter( + index: index, + currentLevel: currentLevel, + desiredLevel: desiredLevel, + skills: skills, + currentAscensionLevel: currentAscensionLevel, + desiredAscensionLevel: desiredAscensionLevel, + ); + context.read().add(event); Navigator.of(context).pop(); } } - -class AscensionLevel extends StatelessWidget { - final bool isCurrentLevel; - final int level; - - const AscensionLevel({ - Key key, - @required this.isCurrentLevel, - @required this.level, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - final widgets = []; - - for (var i = CalculatorAscMaterialsItemBloc.minAscensionLevel; i <= CalculatorAscMaterialsItemBloc.maxAscensionLevel; i++) { - final isSelected = level > 0 && i <= level; - final button = IconButton( - icon: Opacity( - opacity: isSelected ? 1 : 0.2, - child: Image.asset(Assets.getOtherMaterialPath('mark_wind_crystal.png'), width: 40, height: 40), - ), - onPressed: () { - final newValue = i == CalculatorAscMaterialsItemBloc.minAscensionLevel && isSelected ? 0 : i; - final bloc = context.read(); - if (isCurrentLevel) { - bloc.add(CalculatorAscMaterialsItemEvent.currentLevelChanged(newValue: newValue)); - } else { - bloc.add(CalculatorAscMaterialsItemEvent.desiredLevelChanged(newValue: newValue)); - } - }, - ); - widgets.add(button); - } - - return Wrap( - crossAxisAlignment: WrapCrossAlignment.center, - alignment: WrapAlignment.center, - children: widgets, - ); - } -} diff --git a/lib/presentation/calculator_asc_materials/widgets/ascension_level.dart b/lib/presentation/calculator_asc_materials/widgets/ascension_level.dart new file mode 100644 index 000000000..142cc85d7 --- /dev/null +++ b/lib/presentation/calculator_asc_materials/widgets/ascension_level.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:genshindb/application/bloc.dart'; +import 'package:genshindb/domain/assets.dart'; + +class AscensionLevel extends StatelessWidget { + final bool isCurrentLevel; + final int level; + + const AscensionLevel({ + Key key, + @required this.isCurrentLevel, + @required this.level, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + final widgets = []; + + for (var i = CalculatorAscMaterialsItemBloc.minAscensionLevel; i <= CalculatorAscMaterialsItemBloc.maxAscensionLevel; i++) { + final isSelected = level > 0 && i <= level; + final button = IconButton( + icon: Opacity( + opacity: isSelected ? 1 : 0.2, + child: Image.asset(Assets.getOtherMaterialPath('mark_wind_crystal.png'), width: 40, height: 40), + ), + onPressed: () { + final newValue = i == CalculatorAscMaterialsItemBloc.minAscensionLevel && isSelected ? 0 : i; + final bloc = context.read(); + if (isCurrentLevel) { + bloc.add(CalculatorAscMaterialsItemEvent.currentLevelChanged(newValue: newValue)); + } else { + bloc.add(CalculatorAscMaterialsItemEvent.desiredLevelChanged(newValue: newValue)); + } + }, + ); + widgets.add(button); + } + + return Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + alignment: WrapAlignment.center, + children: widgets, + ); + } +} diff --git a/lib/presentation/calculator_asc_materials/widgets/item_card.dart b/lib/presentation/calculator_asc_materials/widgets/item_card.dart index e50d3ca4d..3749500bc 100644 --- a/lib/presentation/calculator_asc_materials/widgets/item_card.dart +++ b/lib/presentation/calculator_asc_materials/widgets/item_card.dart @@ -129,11 +129,14 @@ class ItemCard extends StatelessWidget { context.read().add( CalculatorAscMaterialsItemEvent.loadWith( - key: itemKey, - isCharacter: currentData.isCharacter, - currentLevel: currentData.currentLevel, - desiredLevel: currentData.desiredLevel, - skills: currentData.skills), + key: itemKey, + isCharacter: currentData.isCharacter, + currentLevel: currentData.currentLevel, + desiredLevel: currentData.desiredLevel, + skills: currentData.skills, + currentAscensionLevel: currentData.currentAscensionLevel, + desiredAscensionLevel: currentData.desiredAscensionLevel, + ), ); await showModalBottomSheet( diff --git a/lib/presentation/calculator_asc_materials/widgets/skill_item.dart b/lib/presentation/calculator_asc_materials/widgets/skill_item.dart index 74e00674b..30cb06b57 100644 --- a/lib/presentation/calculator_asc_materials/widgets/skill_item.dart +++ b/lib/presentation/calculator_asc_materials/widgets/skill_item.dart @@ -25,7 +25,7 @@ class SkillItem extends StatelessWidget { return Column( children: [ - Text(name, style: theme.textTheme.subtitle2), + Text(name, style: theme.textTheme.subtitle2, overflow: TextOverflow.ellipsis), const Divider(), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, diff --git a/pubspec.lock b/pubspec.lock index ccc2c7f1b..c26849040 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -422,6 +422,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.6.7" + infinite_listview: + dependency: transitive + description: + name: infinite_listview + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1+1" intl: dependency: transitive description: @@ -548,6 +555,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + numberpicker: + dependency: "direct main" + description: + name: numberpicker + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" package_config: dependency: transitive description: @@ -890,7 +904,7 @@ packages: source: hosted version: "1.0.0" tuple: - dependency: transitive + dependency: "direct main" description: name: tuple url: "https://pub.dartlang.org" diff --git a/pubspec.yaml b/pubspec.yaml index ecc820817..7a5497b62 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -46,6 +46,7 @@ dependencies: json_annotation: ^3.1.0 log_4_dart_2: ^0.4.0 moor: ^3.4.0 + numberpicker: ^1.3.0 package_info: ^0.4.3+4 path: ^1.7.0 path_provider: ^1.6.27 @@ -57,6 +58,7 @@ dependencies: sprintf: ^5.0.0 sqlite3_flutter_libs: ^0.2.0 transparent_image: 1.0.0 + tuple: ^1.0.3 url_launcher: 5.7.10 dev_dependencies: