Improving views and navitation of Tweets.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2021-08-21 19:47:09 -05:00
parent 907deb5752
commit 11b95e0b19
17 changed files with 86 additions and 8 deletions

View File

@ -0,0 +1,14 @@
accessing
asCardElement
^ BrHorizontalPane new
hFitContent;
vFitContent;
padding: (BlInsets all: 20);
margin: (BlInsets all: 10);
addChild: (self user profileImage asElement asScalableElement size: 64@64);
addChild: (BrVerticalPane new
fitContent;
margin: (BlInsets left: 20);
addChild: (BrLabel new aptitude: BrGlamorousLabelAptitude; text: self created);
addChild: (BrLabel new aptitude: BrGlamorousLabelAptitude; text: self text));
when: BlClickEvent do: [:e | e target phlow spawnObject: self]

View File

@ -4,6 +4,6 @@ fromDictionary: aDictionary
text := aDictionary at: 'text'.
id := aDictionary at: 'id'.
authorId := aDictionary at: 'author_id'.
username := aDictionary at: 'username' ifAbsent: [''] .
user := aDictionary at: 'username' ifAbsent: [''] .
conversationId := aDictionary at: 'conversation_id' ifAbsent: [ '' ].
^ self

View File

@ -0,0 +1,3 @@
accessing
user: aTwitterUser
user := aTwitterUser

View File

@ -0,0 +1,3 @@
accessing
user
^ user

View File

@ -11,7 +11,7 @@
"id",
"authorId",
"conversationId",
"username"
"user"
],
"name" : "Tweet",
"type" : "normal"

View File

@ -0,0 +1,3 @@
accessing
add: aTweet
self tweets add: aTweet

View File

@ -0,0 +1,26 @@
accessing
gtTweetsFor: aView
<gtView>
^ aView explicit
title: 'Tweets';
stencil: [
| container imageContainer |
container := BlElement new
layout: BlFlowLayout new;
constraintsDo: [ :c |
c vertical fitContent.
c horizontal matchParent ];
padding: (BlInsets all: 10).
self tweets do: [ :each |
imageContainer := BlLazyElement new
withGlamorousPreview;
aptitude: BrShadowAptitude new;
background: Color white;
margin: (BlInsets all: 20);
constraintsDo: [ :c |
c vertical exact: 100.
c horizontal exact: 1000 ];
elementBuilder: [ each asCardElement margin: (BlInsets all: 20) ].
container addChild: imageContainer].
container asScrollableElement ]

View File

@ -0,0 +1,5 @@
accessing
printOn: aStream
super printOn: aStream.
aStream
nextPutAll: '( ',self size asString, ' Tweet(s) )'

View File

@ -0,0 +1,3 @@
accessing
size
^ self tweets size

View File

@ -0,0 +1,3 @@
accessing
tweets: aTweetsCollection
^ tweets := aTweetsCollection

View File

@ -0,0 +1,3 @@
accessing
tweets
^ tweets ifNil: [ tweets := OrderedCollection new]

View File

@ -0,0 +1,13 @@
{
"commentStamp" : "",
"super" : "Object",
"category" : "Datanalitica-Datanalitica",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"tweets"
],
"name" : "TweetsCollection",
"type" : "normal"
}

View File

@ -5,8 +5,10 @@ messagesAuthors
groupedTweets := self data groupedBy: [:each | each at: 'author_id' ].
^ (self includes at: 'users') collect: [:userDict | | user |
user := TwitterUser new fromDictionary: userDict.
(groupedTweets at: (user id)) do: [:tweetDict |
user tweets add: (Tweet new fromDictionary: tweetDict)
(groupedTweets at: (user id)) do: [:tweetDict | | currentTweet |
currentTweet := Tweet new fromDictionary: tweetDict.
currentTweet user: user.
user tweets add: currentTweet.
].
user.
]

View File

@ -1,5 +1,5 @@
accessing
gtViewContactDetailsOn: aView
gtViewProfileDetailsOn: aView
<gtView>
^ aView explicit
title: 'Details' translated;

View File

@ -4,13 +4,13 @@ profileImage
response := ZnClient new url: (self profileImageUrl); get; response.
response contentType = ZnMimeType imageJpeg
ifTrue: [ | imageTemp |
imageTemp := [JPEGReadWriter gtFromBuffer: response contents].
imageTemp := [ JPEGReadWriter gtFromBuffer: response contents ].
imageTemp on: Error do: [ ^ GtABContact new avatar ].
^ imageTemp value asElement
].
response contentType = ZnMimeType imagePng
ifTrue: [ | imageTemp |
imageTemp := [PNGReadWriter gtFromBuffer: response contents].
imageTemp := [ PNGReadWriter gtFromBuffer: response contents ].
imageTemp on: Error do: [ ^ GtABContact new avatar ].
^ imageTemp value asElement
].

View File

@ -1,3 +1,3 @@
accessing
tweets
^ tweets ifNil: [ tweets := OrderedCollection new]
^ tweets ifNil: [ tweets := TweetsCollection new]