content: ' Credit: https://raw.githubusercontent.com/plexinc/roku-client-public/3a1654bb89edacbe110d86a95cb15501df5fb89b/Plex/source/PhotoSpringboardScreen.brs
  
  Function itemIsPhoto(item) As Boolean
      return item <> invalid AND item.MediaType = "Photo"
  End Function
  
  Function createPhotoSpringboardScreen(context, index, viewController) As Object
      obj = createBaseSpringboardScreen(context, index, viewController, itemIsPhoto)
  
      obj.SetupButtons = photoSetupButtons
      obj.GetMediaDetails = photoGetMediaDetails
  
      obj.superHandleMessage = obj.HandleMessage
      obj.HandleMessage = photoHandleMessage
  
      return obj
  End Function
  
  Sub photoSetupButtons()
      m.ClearButtons()
  
      m.AddButton("Show", "show")
      m.AddButton("Slideshow", "slideshow")
      m.AddButton("Next Photo", "next")
      m.AddButton("Previous Photo", "prev")
  
      'm.AddRatingButton(m.metadata.UserRating, m.metadata.StarRating, "ratePhoto")
  	
  End Sub
  
  Sub photoGetMediaDetails(content)
      m.metadata = content
      m.media = invalid
  End Sub
  
  Function photoHandleMessage(msg) As Boolean
      handled = false
  
      if type(msg) = "roSpringboardScreenEvent" then
          if msg.isButtonPressed() then
              handled = true
              buttonCommand = m.buttonCommands[str(msg.getIndex())]
              Debug("Button command: " + tostr(buttonCommand))
              if buttonCommand = "show" then
                  Debug("photoHandleMessage:: Show photo fullscreen")
                  m.ViewController.CreatePhotoPlayer(m.Item)
              else if buttonCommand = "slideshow" then
                  Debug("photoHandleMessage:: Start slideshow")
                  m.ViewController.CreatePhotoPlayer(m.Context, m.CurIndex, true, m.IsShuffled)
              else if buttonCommand = "next" then
                  Debug("photoHandleMessage:: show next photo")
                   m.GotoNextItem()
              else if buttonCommand = "prev" then
                  Debug("photoHandleMessage:: show previous photo")
                   m.GotoPrevItem()
              else if buttonCommand = "ratePhoto" then
                  Debug("photoHandleMessage:: Rate photo for key " + tostr(m.metadata.ratingKey))
                  rateValue% = (msg.getData() /10)
                  m.metadata.UserRating = msg.getdata()
                  if m.metadata.ratingKey = invalid then
                      m.metadata.ratingKey = 0
                  end if
                  m.Item.server.Rate(m.metadata.ratingKey, m.metadata.mediaContainerIdentifier,rateValue%.ToStr())
              else if buttonCommand = "more" then
                  dialog = createBaseDialog()
                  dialog.Title = ""
                  dialog.Text = ""
                  dialog.Item = m.metadata
                  if m.IsShuffled then
                      dialog.SetButton("shuffle", "Shuffle: On")
                  else
                      dialog.SetButton("shuffle", "Shuffle: Off")
                  end if
                  dialog.SetButton("rate", "_rate_")
                  dialog.SetButton("close", "Back")
                  dialog.HandleButton = photoDialogHandleButton
                  dialog.ParentScreen = m
                  dialog.Show()
              else
                  handled = false
              end if
          end if
      end if
  
      return handled OR m.superHandleMessage(msg)
  End Function
  
  Function photoDialogHandleButton(command, data) As Boolean
      ' We're evaluated in the context of the dialog, but we want to be in
      ' the context of the original screen.
      obj = m.ParentScreen
  
      if command = "delete" then
          obj.metadata.server.delete(obj.metadata.key)
          obj.closeOnActivate = true
          return true
      else if command = "shuffle" then
          if obj.IsShuffled then
              obj.Unshuffle()
              obj.IsShuffled = false
              m.SetButton(command, "Shuffle: Off")
          else
              obj.Shuffle()
              obj.IsShuffled = true
              m.SetButton(command, "Shuffle: On")
          end if
          m.Refresh()
      else if command = "rate" then
          Debug("photoHandleMessage:: Rate audio for key " + tostr(obj.metadata.ratingKey))
          rateValue% = (data /10)
          obj.metadata.UserRating = data
          if obj.metadata.ratingKey <> invalid then
              obj.Item.server.Rate(obj.metadata.ratingKey, obj.metadata.mediaContainerIdentifier, rateValue%.ToStr())
          end if
      else if command = "close" then
          return true
      end if
      return false
  End Function
  