Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
key fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
woshikie committed Aug 8, 2020
1 parent f7bba4c commit e9fba40
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 17 deletions.
17 changes: 17 additions & 0 deletions lib/classes/api/poe_compact_stash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,25 @@ part 'poe_compact_stash.g.dart';
/// This class briefly describes a stash tab only
class PoeCompactStash {
final String n, id;

@JsonKey(name: 'i')
final int index;

@JsonKey(fromJson: _colorFromJson, toJson: _colorToJson)
final Color color;

static Color _colorFromJson(dynamic json) {
return Color.fromARGB(255, json.r, json.g, json.b);
}

static Map<String, int> _colorToJson(Color color) {
return {
'r': color.red,
'g': color.green,
'b': color.blue,
};
}

PoeCompactStash(this.n, this.id, this.index, this.color);

factory PoeCompactStash.fromJson(Map<String, dynamic> json) => _$PoeCompactStashFromJson(json);
Expand Down
7 changes: 4 additions & 3 deletions lib/classes/api/poe_compact_stash.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions lib/classes/collection_piece.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,29 @@ class CollectionPiece {
int _count;

///Count required to be a set
int _setCount;
int setRequiredCount;

CollectionPiece({
@required this.name,
int count,
int setCount,
}) : _count = count == null ? 0 : count,
_setCount = setCount == null ? 1 : setCount;
setRequiredCount = setCount == null ? 1 : setCount;

factory CollectionPiece.fromJson(Map<String, dynamic> json) => _$CollectionPieceFromJson(json);
Map<String, dynamic> toJson() => _$CollectionPieceToJson(this);

/// returns [true] if there is enough counts of this piece to be considered a set
bool get hasSet {
return _count >= _setCount;
if (setRequiredCount == null) return false;
return _count >= setRequiredCount;
}

/// returns number of set
@JsonKey(ignore: true)
int get setCount {
try {
return (_count / _setCount).floor();
return (_count / setRequiredCount).floor();
} catch (e) {
return 0;
}
Expand All @@ -50,7 +53,7 @@ class CollectionPiece {
}

void removeSet({times = 1}) {
_count -= (_setCount * times);
_count -= (setRequiredCount * times);
assert(_count >= 0, 'Removed too much sets!');
}
}
5 changes: 2 additions & 3 deletions lib/classes/collection_piece.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/views/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ class _HomeState extends State<Home> {
List<List<String>> resultList = await Future.wait(futures);
List<String> results = resultList.expand((element) => element).toList();
setState(() {
collection.clearAll();
for (int i = 0; i < patterns.length; i++) {
//collection.pieces[i].count = min(collection.pieces[i].count, results.where((element) => element.contains(patterns[i])).toList().length);
collection.pieces[i].count = results.where((element) => element.contains(patterns[i])).toList().length;
}
saveCollection();
});

_timer = Timer(Duration(milliseconds: Home.REFRESH_DELAY), fetchAPI);
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ packages:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.39.15"
version: "0.39.14"
archive:
dependency: transitive
description:
Expand Down Expand Up @@ -72,7 +72,7 @@ packages:
source: hosted
version: "2.1.4"
build_resolvers:
dependency: transitive
dependency: "direct overridden"
description:
name: build_resolvers
url: "https://pub.dartlang.org"
Expand All @@ -84,7 +84,7 @@ packages:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
version: "1.10.1"
build_runner_core:
dependency: transitive
description:
Expand Down Expand Up @@ -638,5 +638,5 @@ packages:
source: hosted
version: "2.2.1"
sdks:
dart: ">=2.9.0-14.0.dev <3.0.0"
dart: ">=2.9.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
9 changes: 7 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 0.1.2

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.9.0 <3.0.0"

dependencies:
flutter:
Expand All @@ -21,9 +21,14 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: 1.10.1
flutter_launcher_icons: ^0.7.5
json_serializable: ^3.3.0
build_runner: ^1.9.0

#dependency_overrides:
# analyzer: '0.39.14'
dependency_overrides:
build_resolvers: 1.3.10

flutter:
uses-material-design: true
Expand Down

0 comments on commit e9fba40

Please sign in to comment.