mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-23 19:16:09 +00:00
redesign user object
This commit is contained in:
parent
5c663c5596
commit
7235d8c9c2
2 changed files with 34 additions and 62 deletions
|
@ -45,11 +45,11 @@ class AddressResolver {
|
||||||
final formattedName = text.substring(1);
|
final formattedName = text.substring(1);
|
||||||
final twitterUser = await TwitterApi.lookupUserByName(userName: formattedName);
|
final twitterUser = await TwitterApi.lookupUserByName(userName: formattedName);
|
||||||
final addressFromBio = extractAddressByType(
|
final addressFromBio = extractAddressByType(
|
||||||
raw: twitterUser.data.description, type: CryptoCurrency.fromString(ticker));
|
raw: twitterUser.description, type: CryptoCurrency.fromString(ticker));
|
||||||
if (addressFromBio != null) {
|
if (addressFromBio != null) {
|
||||||
return ParsedAddress.fetchTwitterAddress(address: addressFromBio, name: text);
|
return ParsedAddress.fetchTwitterAddress(address: addressFromBio, name: text);
|
||||||
}
|
}
|
||||||
final tweets = twitterUser.includes?.tweets;
|
final tweets = twitterUser.tweets;
|
||||||
if (tweets != null) {
|
if (tweets != null) {
|
||||||
var subString = StringBuffer();
|
var subString = StringBuffer();
|
||||||
tweets.forEach((item) {
|
tweets.forEach((item) {
|
||||||
|
|
|
@ -1,73 +1,45 @@
|
||||||
class TwitterUser {
|
class TwitterUser {
|
||||||
TwitterUser({
|
TwitterUser(
|
||||||
required this.data,
|
{required this.id,
|
||||||
this.includes,
|
required this.username,
|
||||||
});
|
required this.name,
|
||||||
|
required this.description,
|
||||||
|
this.tweets});
|
||||||
|
|
||||||
late final Data data;
|
final String id;
|
||||||
late final Includes? includes;
|
final String username;
|
||||||
|
final String name;
|
||||||
|
final String description;
|
||||||
|
final List<Tweet>? tweets;
|
||||||
|
|
||||||
TwitterUser.fromJson(Map<String, dynamic> json) {
|
factory TwitterUser.fromJson(Map<String, dynamic> json) {
|
||||||
data = Data.fromJson(json['data'] as Map<String, dynamic>);
|
return TwitterUser(
|
||||||
includes = json['includes'] != null
|
id: json['data']['id'] as String,
|
||||||
? Includes.fromJson(json['includes'] as Map<String, dynamic>)
|
username: json['data']['username'] as String,
|
||||||
: null;
|
name: json['data']['name'] as String,
|
||||||
|
description: json['data']['description'] as String,
|
||||||
|
tweets: json['includes'] != null
|
||||||
|
? List.from(json['includes']['tweets'] as List)
|
||||||
|
.map((e) => Tweet.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList()
|
||||||
|
: null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Data {
|
class Tweet {
|
||||||
Data({
|
Tweet({
|
||||||
required this.name,
|
|
||||||
required this.id,
|
|
||||||
required this.pinnedTweetId,
|
|
||||||
required this.description,
|
|
||||||
required this.username,
|
|
||||||
});
|
|
||||||
|
|
||||||
late final String name;
|
|
||||||
late final String id;
|
|
||||||
late final String? pinnedTweetId;
|
|
||||||
late final String description;
|
|
||||||
late final String username;
|
|
||||||
|
|
||||||
Data.fromJson(Map<String, dynamic> json) {
|
|
||||||
name = json['name'] as String;
|
|
||||||
id = json['id'] as String;
|
|
||||||
pinnedTweetId = json['pinned_tweet_id'] as String?;
|
|
||||||
description = json['description'] as String;
|
|
||||||
username = json['username'] as String;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Includes {
|
|
||||||
Includes({
|
|
||||||
required this.tweets,
|
|
||||||
});
|
|
||||||
|
|
||||||
late final List<Tweets> tweets;
|
|
||||||
|
|
||||||
Includes.fromJson(Map<String, dynamic> json) {
|
|
||||||
tweets = List.from(json['tweets'] as Iterable<dynamic>)
|
|
||||||
.map((e) => Tweets.fromJson(e as Map<String, dynamic>))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Tweets {
|
|
||||||
Tweets({
|
|
||||||
required this.editHistoryTweetIds,
|
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.text,
|
required this.text,
|
||||||
});
|
});
|
||||||
|
|
||||||
late final List<String> editHistoryTweetIds;
|
final String id;
|
||||||
late final String id;
|
final String text;
|
||||||
late final String text;
|
|
||||||
|
|
||||||
Tweets.fromJson(Map<String, dynamic> json) {
|
factory Tweet.fromJson(Map<String, dynamic> json) {
|
||||||
editHistoryTweetIds =
|
return Tweet(
|
||||||
List.castFrom<dynamic, String>(json['edit_history_tweet_ids'] as List<dynamic>);
|
id: json['id'] as String,
|
||||||
id = json['id'] as String;
|
text: json['text'] as String,
|
||||||
text = json['text'] as String;
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue