- Getting Started
- Architecture
- The Basics
- Digging Deeper
-
EDGE Components
- Introduction
- Accordion
- Activity Indicator
- Badge
- Bottom Navigation
- Bottom Sheet
- Button
- Button Group
- Canvas
- Carousel
- Checkbox
- Chip
- Column
- Divider
- Floating Action Button
- Gesture Area
- Icon
- Image
- Lazy Grid
- Layout & Styling
- List
- Menus
- Modal
- Pressable
- Progress Bar
- Radio Group
- Pager
- Refreshable
- Row
- Scroll View
- Select
- Shapes
- Side Navigation
- Slider
- Spacer
- Stack
- Tab Row
- Text
- Text Input
- Toggle
- Top Bar
- Virtual List
- Web View
- Plugins
- Testing
- Publishing Your App
System
Overview#
The System API covers system-level concerns — platform detection and opening the app's settings screen.
It's a core built-in: the facade resolves with nothing to install or register.
use Native\Mobile\Facades\System;
Platform detection#
System::isIos(); // true on iOSSystem::isAndroid(); // true on AndroidSystem::isMobile(); // true on either platformSystem::platform(); // 'ios', 'android', or null outside the app
Use these to branch behavior or conditionally render UI for a specific platform. System::platform()
4.7 gives you the answer as a string, which saves checking both.
On the device Changed 4.7, the platform comes from an environment variable the app sets before PHP starts, so these checks are cheap enough to call as often as you like, even once per row of a long list. Before 4.7 every check asked the native side, which was far slower.
Under Jump, PHP runs on your computer instead of the phone, so that variable isn't set. The first check asks the connected device, and the answer is remembered after that.
To render a screen as one platform in a test, see Platform variants.
Each is also available as a global helper function — isIos(), isAndroid(), isMobile() — for terse use in
Blade and components:
if (isAndroid()) { // ...}
In Blade, the same checks are available as conditional directives:
@ios {{-- iOS-only markup --}}@endios @android {{-- Android-only markup --}}@endandroid @mobile {{-- running inside the native app (iOS or Android) --}}@endmobile @web {{-- running in a browser / outside the native app --}}@endweb
Each also supports the usual @else… and @unless… forms — @elseios, @unlessandroid, and so on.
App settings#
Open the app's page in the device Settings app — useful for sending a user to re-grant a permission they previously denied:
System::appSettings();
Appearance (light / dark)#
Reading the current appearance and reacting to theme changes lives with the rest of theming — see
Theming → Appearance in PHP for System::appearance(), isDarkMode(),
isLightMode(), the isDark() / theme() helpers, and the AppearanceChanged event.
Orientation#
Read the orientation of the app window:
System::orientation(); // 'portrait' | 'landscape'System::isPortrait(); // boolSystem::isLandscape(); // bool
When it changes, the OrientationChanged event fires. $orientation is 'portrait' or 'landscape':
use Native\Mobile\Attributes\On;use Native\Mobile\Events\System\OrientationChanged; #[On(OrientationChanged::class)]public function rotated(string $orientation): void{ $this->columns = $orientation === 'landscape' ? 4 : 2;}
OrientationChanged broadcasts globally. Next to the #[On] methods of the live
screen, Event::listen hears it anywhere in your app.
in no time