-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/maintenance mode #1347
Feat/maintenance mode #1347
Changes from all commits
52fdf2c
eff2795
952c2e3
f3818a4
78ead34
47e6fb4
7901850
2ff15df
a271ba0
2b98ca4
4d58258
f94be02
f87c670
254004d
7c4a19d
6afcfff
1a76589
7fc77b2
16409bb
d96f15f
4e71121
64907f7
0d5f5d2
52f72d7
14f0056
d58021f
d4721c0
9b8e434
dfbcf02
c362840
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:easy_localization/easy_localization.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
|
||
import '../generated/locale_keys.g.dart'; | ||
import '../utils/constants.dart'; | ||
|
||
|
||
class MaintenanceModeBannerWidget extends StatelessWidget { | ||
const MaintenanceModeBannerWidget({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
color: AppColors.kDarkPurple, | ||
padding: EdgeInsets.symmetric(vertical: 3.h, horizontal: 3.w), | ||
child: Text( | ||
LocaleKeys.maintenance_mode_header.tr(), | ||
style: TextStyle( | ||
color: Colors.white, fontSize: 10.sp, fontWeight: FontWeight.w700), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. format this code. |
||
), | ||
); | ||
} | ||
} | ||
|
||
class MaintenanceModeMessageWidget extends StatelessWidget { | ||
const MaintenanceModeMessageWidget({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
width: 1.sw, | ||
height: 110.h, | ||
color: AppColors.kMainBG, | ||
child: Align( | ||
child: Padding( | ||
padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 40.w), | ||
child: Container( | ||
padding: EdgeInsets.symmetric(vertical: 5.h, horizontal: 10.w), | ||
color: AppColors.kDarkPurple, | ||
child: Text( | ||
LocaleKeys.maintenance_mode_message.tr(), | ||
style: TextStyle(color: Colors.white, fontSize: 10.sp, fontWeight: FontWeight.w500), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import 'package:get_it/get_it.dart'; | |
import 'package:provider/provider.dart'; | ||
import 'package:pylons_wallet/components/loading.dart'; | ||
import 'package:pylons_wallet/components/user_image_widget.dart'; | ||
import 'package:pylons_wallet/components/maintenance_mode_widgets.dart'; | ||
import 'package:pylons_wallet/ipc/ipc_engine.dart'; | ||
import 'package:pylons_wallet/main_prod.dart'; | ||
import 'package:pylons_wallet/pages/home/collection_screen/collection_view_model.dart'; | ||
|
@@ -22,6 +23,7 @@ import 'package:pylons_wallet/utils/screen_responsive.dart'; | |
import 'package:pylons_wallet/utils/svg_util.dart'; | ||
|
||
import '../../generated/locale_keys.g.dart'; | ||
import '../../services/third_party_services/remote_config_service/remote_config_service.dart'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use absolute path |
||
|
||
class HomeScreen extends StatefulWidget { | ||
const HomeScreen({Key? key}) : super(key: key); | ||
|
@@ -39,6 +41,8 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi | |
|
||
CollectionViewModel get collectionViewModel => GetIt.I.get(); | ||
|
||
RemoteConfigService get remoteConfigService => GetIt.I.get(); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
@@ -99,6 +103,8 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi | |
backgroundColor: AppColors.kMainBG, | ||
appBar: buildAppBar(context, provider), | ||
body: provider.pages[provider.selectedIndex], | ||
bottomSheet: | ||
remoteConfigService.getMaintenanceMode() ? const MaintenanceModeMessageWidget() : null, | ||
), | ||
), | ||
), | ||
|
@@ -158,7 +164,7 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi | |
), | ||
Positioned( | ||
top: 0.035.sh, | ||
left: 0.025.sw, | ||
left: 0.86.sw, | ||
child: GestureDetector( | ||
onTap: () { | ||
Navigator.of(context).pushNamed(RouteUtil.ROUTE_SETTINGS); | ||
|
@@ -171,6 +177,12 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi | |
width: 20.w, | ||
)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code formatting not done properly |
||
), | ||
if (remoteConfigService.getMaintenanceMode()) | ||
Positioned( | ||
top: 0.16.sh, | ||
right: 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. format this. |
||
child: const MaintenanceModeBannerWidget(), | ||
), | ||
Positioned( | ||
top: 0.2.sh - 30.r, | ||
left: 0.5.sw - 30.r, | ||
|
@@ -284,6 +296,12 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi | |
width: 20.w, | ||
)), | ||
), | ||
if (remoteConfigService.getMaintenanceMode()) | ||
Positioned( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to create a widget called MaintenanceBanner and use it everywhere? |
||
top: 0.16.sh, | ||
right: 0, | ||
child: const MaintenanceModeBannerWidget(), | ||
), | ||
Positioned( | ||
top: 0.2.sh - 30.r, | ||
left: 0.5.sw - 30.r, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,9 @@ abstract class RemoteConfigService { | |
|
||
/// This method returns the ios app version in the remote config | ||
String getIOSAppVersion(); | ||
|
||
/// This method returns whether the app is in maintenance mode or not | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update documentation it should be like this |
||
bool getMaintenanceMode(); | ||
} | ||
|
||
class RemoteConfigServiceImpl implements RemoteConfigService { | ||
|
@@ -45,6 +48,8 @@ class RemoteConfigServiceImpl implements RemoteConfigService { | |
static String mongoUrl = "MONGO_URL"; | ||
static String skus = "skus"; | ||
|
||
static String maintenanceMode = "MAINTENANCE_MODE"; | ||
|
||
RemoteConfigServiceImpl( | ||
{required this.firebaseRemoteConfig, | ||
required this.crashlyticsHelper}); | ||
|
@@ -93,6 +98,7 @@ class RemoteConfigServiceImpl implements RemoteConfigService { | |
chainId: dotenv.env['CHAIN_ID'], | ||
skus: defaultPylonsSKUs, | ||
mongoUrl: dotenv.env[mongoUrl] ?? "", | ||
maintenanceMode: false, | ||
}); | ||
|
||
firebaseRemoteConfig.setConfigSettings(RemoteConfigSettings( | ||
|
@@ -119,4 +125,9 @@ class RemoteConfigServiceImpl implements RemoteConfigService { | |
String getIOSAppVersion() { | ||
return firebaseRemoteConfig.getString(iosVERSION); | ||
} | ||
|
||
@override | ||
bool getMaintenanceMode() { | ||
return firebaseRemoteConfig.getBool(maintenanceMode); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Mocks generated by Mockito 5.3.2 from annotations | ||
// in pylons_wallet/test/widget_testing/components/maintenance_mode_widgets_test.dart. | ||
// Do not manually edit this file. | ||
|
||
// ignore_for_file: no_leading_underscores_for_library_prefixes | ||
import 'dart:async' as _i4; | ||
|
||
import 'package:mockito/mockito.dart' as _i1; | ||
import 'package:pylons_wallet/services/third_party_services/remote_config_service/remote_config_service.dart' | ||
as _i3; | ||
import 'package:pylons_wallet/utils/base_env.dart' as _i2; | ||
|
||
// ignore_for_file: type=lint | ||
// ignore_for_file: avoid_redundant_argument_values | ||
// ignore_for_file: avoid_setters_without_getters | ||
// ignore_for_file: comment_references | ||
// ignore_for_file: implementation_imports | ||
// ignore_for_file: invalid_use_of_visible_for_testing_member | ||
// ignore_for_file: prefer_const_constructors | ||
// ignore_for_file: unnecessary_parenthesis | ||
// ignore_for_file: camel_case_types | ||
// ignore_for_file: subtype_of_sealed_class | ||
|
||
class _FakeBaseEnv_0 extends _i1.SmartFake implements _i2.BaseEnv { | ||
_FakeBaseEnv_0( | ||
Object parent, | ||
Invocation parentInvocation, | ||
) : super( | ||
parent, | ||
parentInvocation, | ||
); | ||
} | ||
|
||
/// A class which mocks [RemoteConfigService]. | ||
/// | ||
/// See the documentation for Mockito's code generation for more information. | ||
class MockRemoteConfigService extends _i1.Mock | ||
implements _i3.RemoteConfigService { | ||
MockRemoteConfigService() { | ||
_i1.throwOnMissingStub(this); | ||
} | ||
|
||
@override | ||
_i4.Future<dynamic> init() => (super.noSuchMethod( | ||
Invocation.method( | ||
#init, | ||
[], | ||
), | ||
returnValue: _i4.Future<dynamic>.value(), | ||
) as _i4.Future<dynamic>); | ||
@override | ||
_i2.BaseEnv getBaseEnv() => (super.noSuchMethod( | ||
Invocation.method( | ||
#getBaseEnv, | ||
[], | ||
), | ||
returnValue: _FakeBaseEnv_0( | ||
this, | ||
Invocation.method( | ||
#getBaseEnv, | ||
[], | ||
), | ||
), | ||
) as _i2.BaseEnv); | ||
@override | ||
String getAndroidAppVersion() => (super.noSuchMethod( | ||
Invocation.method( | ||
#getAndroidAppVersion, | ||
[], | ||
), | ||
returnValue: '', | ||
) as String); | ||
@override | ||
String getIOSAppVersion() => (super.noSuchMethod( | ||
Invocation.method( | ||
#getIOSAppVersion, | ||
[], | ||
), | ||
returnValue: '', | ||
) as String); | ||
@override | ||
bool getMaintenanceMode() => (super.noSuchMethod( | ||
Invocation.method( | ||
#getMaintenanceMode, | ||
[], | ||
), | ||
returnValue: false, | ||
) as bool); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:pylons_wallet/components/maintenance_mode_widgets.dart'; | ||
import '../extension/size_extension.dart'; | ||
|
||
|
||
void main() { | ||
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
testWidgets('test case for maintenance mode banner widget', (tester) async { | ||
await tester.setScreenSize(); | ||
await tester.testAppForWidgetTesting(const Material( | ||
child: MaintenanceModeBannerWidget())); | ||
await tester.pumpAndSettle(); | ||
final maintenanceModeBannerWidget = find.byType(MaintenanceModeBannerWidget); | ||
await tester.ensureVisible(maintenanceModeBannerWidget); | ||
await tester.pumpAndSettle(const Duration(seconds: 5)); | ||
expect(maintenanceModeBannerWidget, findsOneWidget); | ||
}); | ||
|
||
testWidgets('test case for maintenance mode message widget', (tester) async { | ||
await tester.setScreenSize(); | ||
await tester.testAppForWidgetTesting(const Material( | ||
child: MaintenanceModeMessageWidget())); | ||
await tester.pumpAndSettle(); | ||
final maintenanceModeMessageWidget = find.byType(MaintenanceModeMessageWidget); | ||
await tester.ensureVisible(maintenanceModeMessageWidget); | ||
await tester.pumpAndSettle(const Duration(seconds: 5)); | ||
expect(maintenanceModeMessageWidget, findsOneWidget); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use absolute path instead of relative one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion i will add a linter for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.