-
Notifications
You must be signed in to change notification settings - Fork 43
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 #116 from WalletConnect/chores/refactor
Refactor and bug fixes
- Loading branch information
Showing
25 changed files
with
420 additions
and
383 deletions.
There are no files selected for viewing
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,130 @@ | ||
import 'dart:convert'; | ||
|
||
class Listing { | ||
final String id; | ||
final String name; | ||
final String homepage; | ||
final String imageId; | ||
final int order; | ||
final String? mobileLink; | ||
final String? desktopLink; | ||
final String? webappLink; | ||
final String? appStore; | ||
final String? playStore; | ||
final String? rdns; | ||
final List<Injected>? injected; | ||
|
||
Listing({ | ||
required this.id, | ||
required this.name, | ||
required this.homepage, | ||
required this.imageId, | ||
required this.order, | ||
this.mobileLink, | ||
this.desktopLink, | ||
this.webappLink, | ||
this.appStore, | ||
this.playStore, | ||
this.rdns, | ||
this.injected, | ||
}); | ||
|
||
Listing copyWith({ | ||
String? id, | ||
String? name, | ||
String? homepage, | ||
String? imageId, | ||
int? order, | ||
String? mobileLink, | ||
String? desktopLink, | ||
String? webappLink, | ||
String? appStore, | ||
String? playStore, | ||
String? rdns, | ||
List<Injected>? injected, | ||
}) => | ||
Listing( | ||
id: id ?? this.id, | ||
name: name ?? this.name, | ||
homepage: homepage ?? this.homepage, | ||
imageId: imageId ?? this.imageId, | ||
order: order ?? this.order, | ||
mobileLink: mobileLink ?? this.mobileLink, | ||
desktopLink: desktopLink ?? this.desktopLink, | ||
webappLink: webappLink ?? this.webappLink, | ||
appStore: appStore ?? this.appStore, | ||
playStore: playStore ?? this.playStore, | ||
rdns: rdns ?? this.rdns, | ||
injected: injected ?? this.injected, | ||
); | ||
|
||
factory Listing.fromRawJson(String str) => Listing.fromJson(json.decode(str)); | ||
|
||
String toRawJson() => json.encode(toJson()); | ||
|
||
factory Listing.fromJson(Object? json) { | ||
final j = json as Map<String, dynamic>? ?? {}; | ||
return Listing( | ||
id: j['id'], | ||
name: j['name'], | ||
homepage: j['homepage'], | ||
imageId: j['image_id'], | ||
order: j['order'], | ||
mobileLink: j['mobile_link'], | ||
desktopLink: j['desktop_link'], | ||
webappLink: j['webapp_link'], | ||
appStore: j['app_store'], | ||
playStore: j['play_store'], | ||
rdns: j['rdns'], | ||
injected: j['injected'] == null | ||
? [] | ||
: List<Injected>.from( | ||
j['injected']!.map((x) => Injected.fromJson(x)), | ||
), | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() => { | ||
'id': id, | ||
'name': name, | ||
'homepage': homepage, | ||
'image_id': imageId, | ||
'order': order, | ||
'mobile_link': mobileLink, | ||
'desktop_link': desktopLink, | ||
'webapp_link': webappLink, | ||
'app_store': appStore, | ||
'play_store': playStore, | ||
'rdns': rdns, | ||
'injected': injected == null | ||
? [] | ||
: List<dynamic>.from(injected!.map((x) => x.toJson())), | ||
}; | ||
} | ||
|
||
class Injected { | ||
final String namespace; | ||
final String injectedId; | ||
|
||
Injected({required this.namespace, required this.injectedId}); | ||
|
||
Injected copyWith({String? namespace, String? injectedId}) => Injected( | ||
namespace: namespace ?? this.namespace, | ||
injectedId: injectedId ?? this.injectedId, | ||
); | ||
|
||
factory Injected.fromRawJson(String str) => | ||
Injected.fromJson(json.decode(str)); | ||
|
||
String toRawJson() => json.encode(toJson()); | ||
|
||
factory Injected.fromJson(Map<String, dynamic> json) => Injected( | ||
namespace: json['namespace'], | ||
injectedId: json['injected_id'], | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
'namespace': namespace, | ||
'injected_id': injectedId, | ||
}; | ||
} |
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,3 +1,4 @@ | ||
import 'dart:io'; | ||
import 'dart:math'; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
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
Oops, something went wrong.