chrisjohn82 Posted May 25, 2016 Posted May 25, 2016 Hi, I'm trying to figure out how to use uniplatform. I want to know the platform the user i logging in from, web or mobile and then based on the platform i want to load the right login screen. I saw that somebody posted a thread about this but and i tried to use the code but did not get it to work. Best Regards Christian Quote
asapltda Posted May 25, 2016 Posted May 25, 2016 Hello , review the example of mobile called Hybrid , which I understand can use the main form as login, from there flames the way according to the platform , I'm interested in the same topic , but it seems that should always be two sets the forms , one for mobile and one for desktop and have repeated the code to navigate or use the type of application registered in the main form that is automatically selected system , I would like to review your progress . There is a person who commented on a link to have uncoupled code to the form but lost if trace Quote
bugra Posted May 26, 2016 Posted May 26, 2016 Hi, If we basiccaly write how to detect platform with code it's look like this type TUniPlatforms = set of TUniPlatform; type TMainmForm = class(TUnimForm) procedure UnimFormCreate(Sender: TObject); private { Private declarations } public { Public declarations } uPlat: TUniPlatforms; end; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication; function MainmForm: TMainmForm; begin Result := TMainmForm(UniMainModule.GetFormInstance(TMainmForm)); end; procedure TMainmForm.UnimFormCreate(Sender: TObject); var platform:string; begin uPlat := UniApplication.UniPlatform; if (upPhone in uPlat) then platform:= 'Phone' else if (upTablet in uPlat) then platform:= 'Tablet' else if (upDesktop in uPlat) then platform:= 'PC'; else if (upiPad in uPlat) then platform:= 'iPad' else if (upiPod in uPlat) then platform:= 'iPod' else if (upiPhone in uPlat) then platform:= 'iPhone' else if (upAndroid in uPlat) then platform:= 'Android Mobile Device' else if (upDesktop in uPlat) then platform:= 'Desktop PC'; else if (upAndroid in uPlat) then platform:= 'Android' else if (upiOS in uPlat) then platform:= 'iOS' else if (upDesktop in uPlat) then platform:= 'Desktop OS'; else if (upDesktop in uPlat) then platform:= 'Desktop' else if (upMobile in uPlat) then platform:= 'Mobile'; end; initialization RegisterAppFormClass(TMainmForm); end. In here first set type of TuniPlatform. after then when uniform created you can control which one is working. (this is the same code from Demos/Touch/Detect Platform with little changes) But as @logisticasoft mentioned if you want mobile user's go to mobile login form, desktop user's go to desktop login form, you better make hybrid application. And you can use ActionList for desktop and mobile button which has same code. (action list not working in mobile menus yet but) Quote
chrisjohn82 Posted May 27, 2016 Author Posted May 27, 2016 Hi, I tried the code, i have the following code in my project and i get an error message when i try it from my iphone > Undefined is not an object (evaluating 'new Ext.field.Text') is there something i'm missing ? procedure TMainForm.UniFormCreate(Sender: TObject); begin uPlat := UniApplication.UniPlatform; if (upDesktop in uPlat) then begin form1.Show(); // This is the desktop login form end else if (upMobile in uPlat) then begin form5.Show(); // This is the mobile login form end; end; Best Regards Christian Quote
chrisjohn82 Posted May 27, 2016 Author Posted May 27, 2016 Its looks like the hybrid example is the best solution for me, thanks for the info. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.