Sha256: d29a069cdded92169e3e5bee8480887d63aec8907d6c1c2380c65fdfcc7fa68e

Contents?: true

Size: 1.63 KB

Versions: 442

Compression:

Stored size: 1.63 KB

Contents

module Frameit
  # Responsible for finding the correct device
  class TemplateFinder
    # This will detect the screen size and choose the correct template
    def self.get_template(screenshot)
      return nil if screenshot.mac?

      filename = "Apple #{screenshot.device_name} #{screenshot.color}"

      templates = Dir["#{FrameDownloader.templates_path}/#{filename}.{png,jpg}"] # ~/.frameit folder

      UI.verbose "Looking for #{filename} and found #{templates.count} template(s)"

      if templates.count == 0
        if screenshot.screen_size == Deliver::AppScreenshot::ScreenSize::IOS_35
          UI.important "Unfortunately 3.5\" device frames were discontinued. Skipping screen '#{screenshot.path}'"
          UI.error "Looked for: '#{filename}.png'"
        elsif screenshot.color == Frameit::Color::ROSE_GOLD || screenshot.color == Frameit::Color::GOLD
          # Unfortunately not every device type is available in rose gold or gold
          # This is why we can't have nice things #yatusabes
          # fallback to a white iPhone, which looks similar
          UI.important("Unfortunately device type '#{screenshot.device_name}' is not available in #{screenshot.color}, falling back to silver...")
          screenshot.color = Frameit::Color::SILVER
          return self.get_template(screenshot)
        else
          UI.error("Couldn't find template for screenshot type '#{filename}'")
          UI.error("Please run `fastlane frameit download_frames` to download the latest frames")
        end
        return filename if Helper.test?
        return nil
      else
        return templates.first.tr(" ", "\ ")
      end
    end
  end
end

Version data entries

442 entries across 442 versions & 1 rubygems

Version Path
fastlane-2.74.0.beta.20180106010004 frameit/lib/frameit/template_finder.rb
fastlane-2.73.0 frameit/lib/frameit/template_finder.rb
fastlane-2.73.0.beta.20180105010003 frameit/lib/frameit/template_finder.rb
fastlane-2.73.0.beta.20180104010004 frameit/lib/frameit/template_finder.rb
fastlane-2.73.0.beta.20180103010003 frameit/lib/frameit/template_finder.rb
fastlane-2.72.0 frameit/lib/frameit/template_finder.rb
fastlane-2.72.0.beta.20180102010003 frameit/lib/frameit/template_finder.rb
fastlane-2.72.0.beta.20180101010003 frameit/lib/frameit/template_finder.rb
fastlane-2.72.0.beta.20171231010003 frameit/lib/frameit/template_finder.rb
fastlane-2.71.1 frameit/lib/frameit/template_finder.rb
fastlane-2.72.0.beta.20171230010003 frameit/lib/frameit/template_finder.rb
fastlane-2.72.0.beta.20171229010003 frameit/lib/frameit/template_finder.rb
fastlane-2.72.0.beta.20171228010004 frameit/lib/frameit/template_finder.rb
fastlane-2.71.0 frameit/lib/frameit/template_finder.rb
fastlane-2.71.0.beta.20171227010004 frameit/lib/frameit/template_finder.rb
fastlane-2.71.0.beta.20171226010004 frameit/lib/frameit/template_finder.rb
fastlane-2.71.0.beta.20171225010003 frameit/lib/frameit/template_finder.rb
fastlane-2.71.0.beta.20171224010003 frameit/lib/frameit/template_finder.rb
fastlane-2.71.0.beta.20171223010003 frameit/lib/frameit/template_finder.rb
fastlane-2.71.0.beta.20171222010003 frameit/lib/frameit/template_finder.rb