[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 ]!

"javascript generated code (s8 code follows binary)" self javascriptCodeFollows!
smalltalk.addClass("MobileAppsUI",smalltalk.MobileApplication, ['pages'], 'MobileAppsUI');

smalltalk.bind(smalltalk.MobileAppsUI,"initializePages",0,function () {var self=this;self['@pages']=smalltalk.Array.$$new();return self;},"initialize",unescape("initializePages%0D%0A%09%22%20Private%20-%20Initialize%20the%20pages%20of%20the%20receiver.%20%22%0D%0A%0D%0A%09pages%20%3A%3D%20Array%20new"));

smalltalk.bind(smalltalk.MobileAppsUI,"pages",0,function () {var self=this;((((self['@pages'] || nil) === nil)).mustBeBoolean()==true ? (function(){return self.initializePages();})() : nil); return self['@pages'];;return self;} ,"accessing",unescape("pages%0D%0A%09%22%20Return%20the%20pages%20of%20the%20receiver.%20%22%0D%0A%0D%0A%09pages%20isNil%20ifTrue%3A%20%5B%20self%20initializePages%20%5D.%0D%0A%09%5Epages"));

smalltalk.bind(smalltalk.MobileAppsUI,"pages:",0,function (anObject) {var self=this;self['@pages']=anObject;return self;} ,"accessing",unescape("pages%3A%20anObject%0D%0A%09%22%20Set%20the%20pages%20of%20the%20receiver.%20%22%0D%0A%0D%0A%09pages%20%3A%3D%20anObject"));

smalltalk.bind(smalltalk.MobileAppsUI.$klass,"open",0,function () {var self=this;return self.open_(self.mainSpec().json());;return self;} ,"ui",unescape("open%0D%0A%09%5Eself%20open%3A%20self%20mainSpec%20json"));

smalltalk.bind(smalltalk.MobileAppsUI.$klass,"mainSpec",0,function () {var self=this;return "threads"._minus_gt((1)._minus_gt(self.toolSpec()))._comma("listeners"._minus_gt("needsModel"._minus_gt((function(){return smalltalk.SwikiCodeRobot._at("mobile");}))));;return self;} ,"specs",unescape("mainSpec%0D%0A%09%22%20Return%20the%20main%20UI%20element%20for%20instances%20of%20the%20receiver.%20%22%0D%0A%0D%0A%09%5E%28%23threads%20-%3E%20%281%20-%3E%20self%20toolSpec%29%29%2C%0D%0A%09%20%28%23listeners%20-%3E%20%28%23needsModel%20-%3E%20%5B%20SwikiCodeRobot%20@%20%23mobile%20%5D%29%29"));

smalltalk.bind(smalltalk.MobileAppsUI.$klass,"pagesListSpec",0 ,function () {var self=this;return "class"._minus_gt("MobileEditor")._comma("configuration"._minus_gt("title"._minus_gt("Mobile Applications")._comma("navigationBar"._minus_gt("left"._minus_gt("refresh"._minus_gt((function(coordinator){return coordinator.applicationModel().withPagesIn_tagged_do_(unescape("s8-media"), "app", (function(pages){coordinator.application().pages_(pages);return coordinator.refresh_("list");}));})))))._comma("widgets"._minus_gt("list"._minus_gt("class"._minus_gt("MobileSelector")._comma("configuration"._minus_gt("order"._minus_gt((1))._comma("listeners"._minus_gt("needsTitle"._minus_gt((function(){return unescape("Apps%20in%20s8-media");}))._comma("needsItems"._minus_gt((function(coordinator){return coordinator.application().pages();})))._comma("configureCell:for:in:coordinator:"._minus_gt((function(cell,item,aList,coordinator){return coordinator.configure_title_description_(cell, unescape("%23")._comma(item.first()), item.second());})))._comma("selected:"._minus_gt((function(item,coordinator){return coordinator.application().openPage_in_(item, coordinator);}))))))))))._comma("listeners"._minus_gt("built:"._minus_gt((function(coordinator){return coordinator.buttons().at_("refresh").triggerClick();}))))));;return self;} ,"specs",unescape("pagesListSpec%0D%0A%09%22%20Private%20-%20Specification%20of%20UI%20for%20list%20of%20pages.%20%22%0D%0A%0D%0A%09%5E%28%09%28%23class%20-%3E%20%23MobileEditor%29%2C%0D%0A%09%09%28%23configuration%20-%3E%20%28%0D%0A%09%09%09%28%23title%20-%3E%20%27Mobile%20Applications%27%29%2C%0D%0A%09%09%09%28%23navigationBar%20-%3E%20%28%23left%20-%3E%20%28%23refresh%20-%3E%20%5B%3Acoordinator%20%7C%0D%0A%09%09%09%09coordinator%20applicationModel%0D%0A%09%09%09%09%09withPagesIn%3A%20%23s8-media%20tagged%3A%20%23app%0D%0A%09%09%09%09%09do%3A%20%5B%3Apages%7C%0D%0A%09%09%09%09%09%09coordinator%20application%20pages%3A%20pages.%0D%0A%09%09%09%09%09%09coordinator%20refresh%3A%20%23list%0D%0A%09%09%09%09%09%5D.%0D%0A%09%09%09%5D%29%29%29%2C%0D%0A%09%09%09%28%23widgets%20-%3E%20%28%23list%20-%3E%20%28%0D%0A%09%09%09%09%28%23class%20-%3E%20%23MobileSelector%20%29%2C%0D%0A%09%09%09%09%28%23configuration%20-%3E%28%0D%0A%09%09%09%09%09%28%23order%20-%3E%201%29%2C%0D%0A%09%09%09%09%09%28%23listeners%20-%3E%20%28%0D%0A%09%09%09%09%09%09%28%23needsTitle%20-%3E%20%5B%27Apps%20in%20s8-media%27%5D%20%29%2C%0D%0A%09%09%09%09%09%09%28%23needsItems%20-%3E%20%5B%3Acoordinator%20%7C%20coordinator%20application%20pages%20%5D%20%29%2C%0D%0A%09%09%09%09%09%09%28%23configureCell%3Afor%3Ain%3Acoordinator%3A%20-%3E%20%5B%3Acell%20%3Aitem%20%3AaList%20%3Acoordinator%20%7C%0D%0A%09%09%09%09%09%09%09coordinator%20configure%3A%20cell%20title%3A%20%27%23%27%2Citem%20first%20description%3A%20item%20second%0D%0A%09%09%09%09%09%09%5D%29%2C%0D%0A%09%09%09%09%09%09%28%23selected%3A%20-%3E%20%5B%3Aitem%20%3Acoordinator%20%7C%0D%0A%09%09%09%09%09%09%09coordinator%20application%20openPage%3A%20item%20in%3A%20coordinator%0D%0A%09%09%09%09%09%09%5D%29%0D%0A%09%09%09%09%09%29%29%0D%0A%09%09%09%09%29%29%0D%0A%09%09%09%29%29%20%29%2C%0D%0A%09%09%09%28%23listeners%20-%3E%20%28%23built%3A%20-%3E%20%5B%3Acoordinator%20%7C%20%28coordinator%20buttons%20at%3A%20%23refresh%29%20triggerClick%20%5D%29%29%0D%0A%09%09%09%29%0D%0A%09%09%29%0D%0A%09%29"));

smalltalk.bind(smalltalk.MobileAppsUI.$klass,"toolSpec",0 ,function () {var self=this;return "tool"._minus_gt("swiki")._comma("coordinator"._minus_gt(self.pagesListSpec()));;return self;} ,"specs",unescape("toolSpec%0D%0A%09%22%20Private%20-%20Specification%20of%20UI%20for%20tool.%20%22%0D%0A%0D%0A%09%5E%28%0D%0A%09%09%28%23tool%20-%3E%20%23swiki%20%29%2C%0D%0A%09%09%28%23coordinator%20-%3E%20self%20pagesListSpec%29%0D%0A%09%29"));

smalltalk.bind(smalltalk.MobileAppsUI,"openPage:in:",0,function (aPage, aCoordinator) {var self=this;return self.model().processPageAt_(unescape("swiki%3As8-media/")._comma(aPage.first()));;return self;} ,"actions",unescape("openPage%3A%20aPage%20in%3A%20aCoordinator%0D%0A%09%22%20Private%20-%20Open%20the%20page.%20%22%0D%0A%0D%0A%09%5Eself%20model%20processPageAt%3A%20%27swiki%3As8-media/%27%2CaPage%20first"));

/* S8 source code follows------
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 ].
(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