[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

mobile[apps] code

Goal

  1. Collect pages marked with mobile[app]
  2. Present the application pages in a list
  3. Open the application selected by the user

Implementation

"Loading Mobile Apps UI..."
(Smalltalk includesKey: #MobileAppsUI) ifTrue: [ self cancelFileIn ]!
self nativeLanguage = #js ifTrue: [
	self @> #mobileAppsJsCode.
	^self cancelFileIn
]!

MobileApplication
	subclass: #MobileAppsUI
	instanceVariableNames: #pages
	category: #MobileAppsUI!
MobileAppsUI buildAccessors: #(
	#(pages initialize #Array)
)!

! MobileAppsUI class methodsFor: #ui !
open
	^self open: self mainSpec json! !

! MobileAppsUI class methodsFor: #specs !
mainSpec
	" Return the main UI element for instances of the receiver. "

	^(#threads -> (1 -> self toolSpec)),
	 (#listeners -> (#needsModel -> [ SwikiCodeRobot @ #mobile ]))! !

! MobileAppsUI class methodsFor: #specs !
pagesListSpec
	" Private - Specification of UI for list of pages. "

	^(	(#class -> #MobileEditor),
		(#configuration -> (
			(#title -> 'Mobile Applications'),
			(#navigationBar -> (#left -> (#refresh -> [:coordinator |
				coordinator applicationModel
					withPagesIn: #s8-media tagged: #app
					do: [:pages|
						coordinator application pages: pages.
						coordinator refresh: #list
					].
			]))),
			(#widgets -> (#list -> (
				(#class -> #MobileSelector ),
				(#configuration ->(
					(#order -> 1),
					(#listeners -> (
						(#needsTitle -> ['Apps in s8-media'] ),
						(#needsItems -> [:coordinator | coordinator application pages ] ),
						(#configureCell:for:in:coordinator: -> [:cell :item :aList :coordinator |
							coordinator configure: cell title: '#',item first description: item second
						]),
						(#selected: -> [:item :coordinator |
							coordinator application openPage: item in: coordinator
						])
					))
				))
			)) ),
			(#listeners -> (#built: -> [:coordinator | (coordinator buttons at: #refresh) triggerClick ]))
			)
		)
	)! !

! MobileAppsUI class methodsFor: #specs !
toolSpec
	" Private - Specification of UI for tool. "

	^(
		(#tool -> #swiki ),
		(#coordinator -> self pagesListSpec)
	)! !

! MobileAppsUI methodsFor: #actions !
openPage: aPage in: aCoordinator
	" Private - Open the page. "

	^self model processPageAt: 'swiki:s8-media/',aPage first! !


"Collecting application's pages and open UI"
(Smalltalk includesKey: #MobileAppsUI) ifTrue: [ ^MobileAppsUI open ].
self note: 'Missing MobileAppsUI - See swiki:s8-media/mobileAppsCode'.
(SwikiCodeRobot @ #mobile)
    withPagesIn: #s8-media tagged: #app
    do: [:pages| pages do: [:each| self print: '//page ',each printString ] ]

Screenshot running web

Uploaded Image: MobileAppsUI.jpg

Open the tool


References