Skip to content

Commit

Permalink
⬆️ Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse committed Aug 31, 2022
1 parent e6aa134 commit b39b79b
Show file tree
Hide file tree
Showing 9 changed files with 336 additions and 57 deletions.
2 changes: 1 addition & 1 deletion bin/src/constants/config.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Config {
Config._();

static const String version = '2.1.5';
static const String version = '2.1.6';
static final Uri githubRepositoryUrl =
Uri.https('github.com', '/techouse/alfred-tailwindcss-docs');
static const String algoliaApplicationId = 'KNPXZI5B0M';
Expand Down
41 changes: 25 additions & 16 deletions bin/src/models/search_result.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import 'package:json_annotation/json_annotation.dart';
import 'search_result_hierarchy.dart';

part 'search_result.g.dart';

@JsonSerializable(explicitToJson: true)
class SearchResult {
const SearchResult({
required this.objectID,
Expand Down Expand Up @@ -40,20 +44,25 @@ class SearchResult {

static const String snippetEllipsisText = '...';

SearchResult.fromJson(Map<String, dynamic> json)
: objectID = json['objectID'] as String,
type = json['type'] as String,
url = json['url'] as String,
hierarchy = SearchResultHierarchy.fromJson(
json['hierarchy'] as Map<String, dynamic>,
),
content = json['content'] as String?;

Map<String, dynamic> toJson() => {
'objectID': objectID,
'type': type,
'url': url,
'content': content,
'hierarchy': hierarchy.toJson(),
};
factory SearchResult.fromJson(Map<String, dynamic> json) =>
_$SearchResultFromJson(json);

Map<String, dynamic> toJson() => _$SearchResultToJson(this);

// SearchResult.fromJson(Map<String, dynamic> json)
// : objectID = json['objectID'] as String,
// type = json['type'] as String,
// url = json['url'] as String,
// hierarchy = SearchResultHierarchy.fromJson(
// json['hierarchy'] as Map<String, dynamic>,
// ),
// content = json['content'] as String?;
//
// Map<String, dynamic> toJson() => {
// 'objectID': objectID,
// 'type': type,
// 'url': url,
// 'content': content,
// 'hierarchy': hierarchy.toJson(),
// };
}
25 changes: 25 additions & 0 deletions bin/src/models/search_result.g.dart

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

50 changes: 25 additions & 25 deletions bin/src/models/search_result_hierarchy.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import 'package:json_annotation/json_annotation.dart';

part 'search_result_hierarchy.g.dart';

@JsonSerializable()
class SearchResultHierarchy {
const SearchResultHierarchy({
required this.lvl0,
Expand All @@ -18,32 +23,27 @@ class SearchResultHierarchy {
final String? lvl6;

String? getLevel(int level) {
if (level == 1) return lvl1;
if (level == 2) return lvl2;
if (level == 3) return lvl3;
if (level == 4) return lvl4;
if (level == 5) return lvl5;
if (level == 6) return lvl6;

return lvl0;
switch (level) {
case 1:
return lvl1;
case 2:
return lvl2;
case 3:
return lvl3;
case 4:
return lvl4;
case 5:
return lvl5;
case 6:
return lvl6;
default:
return lvl0;
}
}

SearchResultHierarchy.fromJson(Map<String, dynamic> json)
: lvl0 = json['lvl0'] as String,
lvl1 = json['lvl1'] as String?,
lvl2 = json['lvl2'] as String?,
lvl3 = json['lvl3'] as String?,
lvl4 = json['lvl4'] as String?,
lvl5 = json['lvl5'] as String?,
lvl6 = json['lvl6'] as String?;
factory SearchResultHierarchy.fromJson(Map<String, dynamic> json) =>
_$SearchResultHierarchyFromJson(json);

Map<String, String?> toJson() => {
'lvl0': lvl0,
'lvl1': lvl1,
'lvl2': lvl2,
'lvl3': lvl3,
'lvl4': lvl4,
'lvl5': lvl5,
'lvl6': lvl6,
};
Map<String, String?> toJson() => _$SearchResultHierarchyToJson(this)
.map((key, value) => MapEntry(key, value?.toString()));
}
31 changes: 31 additions & 0 deletions bin/src/models/search_result_hierarchy.g.dart

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

2 changes: 1 addition & 1 deletion info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>2.1.5</string>
<string>2.1.6</string>
<key>webaddress</key>
<string>https://github.com/techouse</string>
</dict>
Expand Down
Loading

0 comments on commit b39b79b

Please sign in to comment.