Skip to content

Commit ab374d0

Browse files
committed
fix: add full screen function
1 parent cd807c4 commit ab374d0

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
@@ -661,6 +661,17 @@ private Typeface getTypeface(Map<String, Object> map, String fileKey, String ass
661661
}
662662
}
663663
}
664-
664+
/**
665+
* Enables or disables displaying in full-screen mode, hiding the status and navigation bars.
666+
* @param isEnabled A boolean to enable/disable setFullscreen.
667+
*/
668+
@Override
669+
public void setFullscreen(@NonNull final Boolean isEnabled) {
670+
try {
671+
Instabug.setFullscreen(isEnabled);
672+
} catch (Exception e) {
673+
e.printStackTrace();
674+
}
675+
}
665676

666677
}

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

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

711+
@Test
712+
public void testSetFullscreen() {
713+
boolean isEnabled = true;
714+
715+
api.setFullscreen(isEnabled);
716+
717+
mInstabug.verify(() -> Instabug.setFullscreen(isEnabled));
718+
}
719+
720+
@Test
721+
public void testSetFullscreenDisabled() {
722+
boolean isEnabled = false;
723+
724+
api.setFullscreen(isEnabled);
725+
726+
mInstabug.verify(() -> Instabug.setFullscreen(isEnabled));
727+
}
728+
711729

712730
}

example/ios/InstabugTests/InstabugApiTests.m

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

642+
- (void)testSetFullscreen {
643+
NSNumber *isFullscreen = @1;
644+
FlutterError *error;
645+
646+
[self.api setFullscreenIsFullscreen:isFullscreen error:&error];
647+
648+
XCTAssertNil(error);
649+
}
650+
642651
@end

ios/Classes/Modules/InstabugApi.m

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

569+
- (void)setFullscreenIsFullscreen:(NSNumber *)isFullscreen error:(FlutterError *_Nullable *_Nonnull)error {
570+
// Empty implementation as requested
571+
}
572+
569573
@end

lib/src/modules/instabug.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,4 +510,16 @@ class Instabug {
510510
static Future<void> setTheme(ThemeConfig themeConfig) async {
511511
return _host.setTheme(themeConfig.toMap());
512512
}
513+
514+
/// Sets the fullscreen mode for Instabug UI.
515+
///
516+
/// [isFullscreen] - Whether to enable fullscreen mode or not.
517+
///
518+
/// Example:
519+
/// ```dart
520+
/// Instabug.setFullscreen(true);
521+
/// ```
522+
static Future<void> setFullscreen(bool isEnabled) async {
523+
return _host.setFullscreen(isEnabled);
524+
}
513525
}

pigeons/instabug.api.dart

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

8080
void setTheme(Map<String, Object> themeConfig);
81+
void setFullscreen(bool isEnabled);
8182
}

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)