Class: Shuttlecraft::MothershipApp

Inherits:
Object
  • Object
show all
Defined in:
lib/shuttlecraft/mothership_app.rb

Class Method Summary collapse

Class Method Details

.runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/shuttlecraft/mothership_app.rb', line 3

def self.run
  Shoes.app width: 360, height: 360, resizeable: false, title: 'Mothership' do
    @mothership = nil

    def launch_screen
      clear do
        background black
        title "Build Mothership", stroke: white
        edit_line text: 'Name' do |s|
          @name = s.text
        end
        button('launch') {
          @mothership = Shuttlecraft::Mothership.new(name: @name)
          display_screen
        }
      end
    end

    def display_screen
      clear do
        background "#ffffff"

        stack :margin => 20 do
          title "Mothership #{@mothership.name}"

          stack do
            para 'Registered Services:'
            @registrations = para
          end
        end
        animate(5) { @registrations.replace registrations_text }
      end
    end

    def registrations_text
      if @mothership
        @mothership.registered_services.join(', ')
      end
    end

    launch_screen
  end
end