Skip to content

Commit 70e44ce

Browse files
committed
fix: add full screen function
1 parent b4b89be commit 70e44ce

File tree

7 files changed

+76
-1
lines changed

7 files changed

+76
-1
lines changed

android/src/main/java/com/instabug/flutter/modules/InstabugApi.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,17 @@ private Typeface getTypeface(Map<String, Object> map, String fileKey, String ass
681681
}
682682
}
683683
}
684-
684+
/**
685+
* Enables or disables displaying in full-screen mode, hiding the status and navigation bars.
686+
* @param isEnabled A boolean to enable/disable setFullscreen.
687+
*/
688+
@Override
689+
public void setFullscreen(@NonNull final Boolean isEnabled) {
690+
try {
691+
Instabug.setFullscreen(isEnabled);
692+
} catch (Exception e) {
693+
e.printStackTrace();
694+
}
695+
}
685696

686697
}

android/src/test/java/com/instabug/flutter/InstabugApiTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,5 +720,23 @@ public void testSetThemeWithAllProperties() {
720720
mInstabug.verify(() -> Instabug.setTheme(any(com.instabug.library.model.IBGTheme.class)));
721721
}
722722

723+
@Test
724+
public void testSetFullscreen() {
725+
boolean isEnabled = true;
726+
727+
api.setFullscreen(isEnabled);
728+
729+
mInstabug.verify(() -> Instabug.setFullscreen(isEnabled));
730+
}
731+
732+
@Test
733+
public void testSetFullscreenDisabled() {
734+
boolean isEnabled = false;
735+
736+
api.setFullscreen(isEnabled);
737+
738+
mInstabug.verify(() -> Instabug.setFullscreen(isEnabled));
739+
}
740+
723741

724742
}

example/ios/InstabugTests/InstabugApiTests.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,4 +646,13 @@ - (void)testSetThemeWithAllProperties {
646646
OCMVerify([self.mInstabug setTheme:[OCMArg isNotNil]]);
647647
}
648648

649+
- (void)testSetFullscreen {
650+
NSNumber *isFullscreen = @1;
651+
FlutterError *error;
652+
653+
[self.api setFullscreenIsFullscreen:isFullscreen error:&error];
654+
655+
XCTAssertNil(error);
656+
}
657+
649658
@end

ios/Classes/Modules/InstabugApi.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,4 +579,8 @@ - (UIColor *)colorFromHexString:(NSString *)hexString {
579579
return [UIColor blackColor];
580580
}
581581

582+
- (void)setFullscreenIsFullscreen:(NSNumber *)isFullscreen error:(FlutterError *_Nullable *_Nonnull)error {
583+
// Empty implementation as requested
584+
}
585+
582586
@end

lib/src/modules/instabug.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,4 +521,16 @@ class Instabug {
521521
static Future<void> setTheme(ThemeConfig themeConfig) async {
522522
return _host.setTheme(themeConfig.toMap());
523523
}
524+
525+
/// Sets the fullscreen mode for Instabug UI.
526+
///
527+
/// [isFullscreen] - Whether to enable fullscreen mode or not.
528+
///
529+
/// Example:
530+
/// ```dart
531+
/// Instabug.setFullscreen(true);
532+
/// ```
533+
static Future<void> setFullscreen(bool isEnabled) async {
534+
return _host.setFullscreen(isEnabled);
535+
}
524536
}

pigeons/instabug.api.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,5 @@ abstract class InstabugHostApi {
108108
void setNetworkLogBodyEnabled(bool isEnabled);
109109

110110
void setTheme(Map<String, Object> themeConfig);
111+
void setFullscreen(bool isEnabled);
111112
}

test/instabug_test.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,24 @@ void main() {
474474
mHost.willRedirectToStore(),
475475
).called(1);
476476
});
477+
478+
test('[setFullscreen] should call host method', () async {
479+
const isEnabled = true;
480+
481+
await Instabug.setFullscreen(isEnabled);
482+
483+
verify(
484+
mHost.setFullscreen(isEnabled),
485+
).called(1);
486+
});
487+
488+
test('[setFullscreen] should call host method with false', () async {
489+
const isEnabled = false;
490+
491+
await Instabug.setFullscreen(isEnabled);
492+
493+
verify(
494+
mHost.setFullscreen(isEnabled),
495+
).called(1);
496+
});
477497
}

0 commit comments

Comments
 (0)