Exemplo n.º 1
0
 def __init__(self, replyid, body, voteCount, previousvote, uname, ucolor, timestamp, tint, *args, **kwargs):
     super(replyCell, self).__init__(**kwargs)
     
     previousvote = int(previousvote)
     
     timeSincePost = int(time.time()) - int(timestamp)
     
     UserColor = ucolor.split(',');
     
     if tint == True:
         with self.canvas:
             Color(0.78823529411, 0.78823529411, 0.78823529411, 0.35)
             self.background = Rectangle(size=self.size, pos=self.pos)
        
         self.bind(pos=self.updateCanvas, size=self.updateCanvas)
     
     replyBody = Label(text=body, pos_hint={'x':0.0175, 'center_y':0.55}, size_hint=(0.7, 0.9), text_size=(dp(250), dp(90)), font_size="15sp", color=(0,0,0,1), halign="left", valign="middle")
     
     username = Label(text=uname, pos_hint={'x':0.0175, 'y':0.0175}, size_hint=(0.7, 0.3), text_size=(dp(250), dp(35)), font_size="13sp", color=(float(UserColor[0]), float(UserColor[1]), float(UserColor[2]), 0.5), halign="left")
     
     votes = Label(text=voteCount, pos_hint={'right':0.9825, 'center_y':0.5}, size_hint=(0.25, None), text_size=(None, None), font_size="20sp", color=(0,0,0,1))
     voteButtons = BoxLayout(orientation="horizontal", size_hint=(0.25, 0.25), pos_hint={'right':0.9825, 'y':0.05})
     
     upvote = imageButtonLocal(source="", size_hint_x=0.5)
     downvote = imageButtonLocal(source="", size_hint_x=0.5)
     
     if previousvote != 0:
         if previousvote == 1:
             upvote.source = "data/up_clicked.png"
             upvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, 0))
             downvote.source = "data/down_unclicked.png"
             downvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, -2))
         else:
             upvote.source = "data/up_unclicked.png"
             upvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, 2))
             downvote.source = "data/down_clicked.png"
             downvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, 0))
                                            
     else:
         upvote.source = "data/up_unclicked.png"
         upvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, 1))
         downvote.source = "data/down_unclicked.png"
         downvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, -1))
     
     upvote.bind(on_press=lambda upvt: vote(App.get_running_app().backend, App.get_running_app().usrid, replyid, "upvote", "reply"))
     downvote.bind(on_press=lambda dnvt: vote(App.get_running_app().backend, App.get_running_app().usrid, replyid, "downvote", "reply"))
     
     voteButtons.add_widget(upvote)
     voteButtons.add_widget(downvote)
     
     timeSince = Label(text=formatTime(timeSincePost), pos_hint={'right':0.9825, 'top':0.9825}, size_hint=(0.7, 0.25), text_size=(dp(250), dp(35)), font_size="13sp", color=(0.11764705882352941, 0.4588235294117647, 0.8, 0.5), halign="right", valign="top")
     
     self.add_widget(replyBody)
     self.add_widget(username)
     self.add_widget(votes)
     self.add_widget(voteButtons)
     self.add_widget(timeSince)
Exemplo n.º 2
0
    def __init__(self, postid, title, voteCount, previousvote, img, source_url, timestamp, mediaType, caption, tint, *args, **kwargs):
        super(postCell, self).__init__(**kwargs)
        
        self.Title = title
        self.Caption = caption
        
        previousvote = int(previousvote)
        mediaType = int(mediaType)
        timeSincePost = int(time.time()) - int(timestamp)
        
        if tint == True:
            with self.canvas:
                Color(0.78823529411, 0.78823529411, 0.78823529411, 0.35)
                self.background = Rectangle(size=self.size, pos=self.pos)
        
            self.bind(pos=self.updateCanvas, size=self.updateCanvas)
        
        img.bind(on_press=lambda thumbbtn: Logger.info("flicknik: {} thumbnail pressed".format(postid)))
        
        if mediaType == 0:
            img.bind(on_press=lambda thumbphotoscrn: self.displayMedia(mediaType,source_url,postid))
        elif mediaType == 1:
            img.bind(on_press=lambda thumbphotoscrn: self.displayMedia(mediaType,source_url,postid))
        
        postTitle = Label(text=title, pos_hint={'center_x':0.5, 'top':0.7}, size_hint=(0.5, None), text_size=(dp(150), dp(75)), font_size="15sp", color=(0,0,0,1), halign="left", valign="top")
        
        votes = Label(text=voteCount, pos_hint={'right':0.9825, 'center_y':0.5}, size_hint=(0.25, None), text_size=(None, None), font_size="20sp", color=(0,0,0,1))
        voteButtons = BoxLayout(orientation="horizontal", size_hint=(0.25, 0.25), pos_hint={'right':0.9825, 'y':0.05})    
        
        upvote = imageButtonLocal(source="", size_hint_x=0.5)
        downvote = imageButtonLocal(source="", size_hint_x=0.5)
        
        if previousvote != 0:
            if previousvote == 1:
                upvote.source = "data/up_clicked.png"
                upvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, 0))
                downvote.source = "data/down_unclicked.png"
                downvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, -2))
            else:
                upvote.source = "data/up_unclicked.png"
                upvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, 2))
                downvote.source = "data/down_clicked.png"
                downvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, 0))
                                               
        else:
            upvote.source = "data/up_unclicked.png"
            upvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, 1))
            downvote.source = "data/down_unclicked.png"
            downvote.bind(on_press=lambda vtcnt: updateVoteDisplay(upvote, downvote, votes, voteCount, -1))
        
        upvote.bind(on_press=lambda upvt: vote(App.get_running_app().backend, App.get_running_app().usrid, postid, "upvote", "submission"))
        downvote.bind(on_press=lambda dnvt: vote(App.get_running_app().backend, App.get_running_app().usrid, postid, "downvote", "submission"))
        
        voteButtons.add_widget(upvote)
        voteButtons.add_widget(downvote)
        
        # Note: spaces are in the labelbuttons for spacing purposes
        buttonBar = BoxLayout(orientation="horizontal", pos_hint={'center_x':0.5, 'y':0.0175}, size_hint=(0.425, 0.15))
        reply = labelButton(text="Reply   ", font_size="13sp", color=(0.11764705882352941, 0.4588235294117647, 0.8, 0.5))
        reply.bind(on_press=lambda replyqueue: getReplyScreen(postid, title, voteCount, previousvote, img, source_url, timestamp, mediaType, caption))
        report = labelButton(text="Report", font_size="13sp", color=(0.11764705882352941, 0.4588235294117647, 0.8, 0.5))
        report.bind(on_press=lambda reportnotify: self.queuePopup("report", postid))
        block = labelButton(text=" Block", font_size="13sp", color=(0.11764705882352941, 0.4588235294117647, 0.8, 0.5))
        block.bind(on_press=lambda blocknotify: self.queuePopup("block", postid))
        hide = labelButton(text="  Hide", font_size="13sp", color=(0.11764705882352941, 0.4588235294117647, 0.8, 0.5))
        hide.bind(on_press=lambda hidenotify: self.queuePopup("hide", postid))
        
        buttonBar.add_widget(reply)
        buttonBar.add_widget(report)
        buttonBar.add_widget(hide)
        buttonBar.add_widget(block)

        imgholder = BoxLayout(orientation="horizontal", size_hint=(0.25, 1), pos_hint={'right':0.2625, 'top':1})
        imgholder.add_widget(img)
        
        timeSince = Label(text=formatTime(timeSincePost), pos_hint={'right':0.9825, 'top':0.9825}, size_hint=(0.7, 0.25), text_size=(dp(250), dp(35)), font_size="13sp", color=(0.11764705882352941, 0.4588235294117647, 0.8, 0.5), halign="right", valign="top")        
        
        self.add_widget(voteButtons)
        self.add_widget(buttonBar)
        self.add_widget(imgholder)
        self.add_widget(postTitle)
        self.add_widget(votes)
        self.add_widget(timeSince)