Skip to content

Commit

Permalink
Merge pull request #1347 from Pylons-tech/feat/maintenance_mode
Browse files Browse the repository at this point in the history
Feat/maintenance mode
  • Loading branch information
kjawadDeveloper2 authored Nov 11, 2022
2 parents b69e38b + c362840 commit 72b96a1
Show file tree
Hide file tree
Showing 16 changed files with 235 additions and 11 deletions.
Empty file modified wallet/.translations.sh
100644 → 100755
Empty file.
5 changes: 4 additions & 1 deletion wallet/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,8 @@
"retry": "Wiederholen",
"bought_nft": "Gekauft",
"resolution": "Auflösung",
"set_lockscreen": "Instellen als vergrendelscherm"
"set_lockscreen": "Instellen als vergrendelscherm",
"maintenance_mode_message": "We ondervinden technische problemen en hebben tijdelijk de onderhoudsmodus gestart voor het oplossen van problemen. Maak je geen zorgen, je collectie is veilig. U kunt echter geen on-chain-transacties starten totdat we het probleem hebben opgelost en de normale functionaliteit hebben hersteld.",
"maintenance_mode_header": "onderhoudsstand"

}
5 changes: 4 additions & 1 deletion wallet/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,8 @@
"please_try_again_later": "Please try again later",
"checkout": "Checkout",
"artist": "Artist",
"set_lockscreen": "Set as lockscreen"
"set_lockscreen": "Set as lockscreen",
"maintenance_mode_message": "We are experiencing technical issues and have temporarily initiated maintenance mode for troubleshooting. Don't worry, your collection is safe. However, you cannot initiate on-chain transactions until we've resolved the problem and restored normal functionality.",
"maintenance_mode_header": "Maintenance Mode"

}
5 changes: 4 additions & 1 deletion wallet/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,8 @@
"retry": "Rever",
"resolution": "resolución",
"bought_nft": "Comprado",
"set_lockscreen": "Establecer como pantalla de bloqueo"
"set_lockscreen": "Establecer como pantalla de bloqueo",
"maintenance_mode_message": "Estamos experimentando problemas técnicos y hemos iniciado temporalmente el modo de mantenimiento para solucionar problemas. No te preocupes, tu colección está segura. Sin embargo, no puede iniciar transacciones en cadena hasta que hayamos resuelto el problema y restablecido la funcionalidad normal.",
"maintenance_mode_header": "Modo de mantenimiento"

}
5 changes: 4 additions & 1 deletion wallet/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,8 @@
"retry": "Mencoba Kembali",
"bought_nft": "Dibeli",
"resolution": "resolusi",
"set_lockscreen": "Tetapkan sebagai layar kunci"
"set_lockscreen": "Tetapkan sebagai layar kunci",
"maintenance_mode_message": "Kami mengalami masalah teknis dan untuk sementara memulai mode pemeliharaan untuk pemecahan masalah. Jangan khawatir, koleksi Anda aman. Namun, Anda tidak dapat memulai transaksi on-chain sampai kami menyelesaikan masalah dan memulihkan fungsionalitas normal.",
"maintenance_mode_header": "Mode Pemeliharaan"

}
5 changes: 4 additions & 1 deletion wallet/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,8 @@
"retry": "リトライ",
"resolution": "解像度",
"bought_nft": "買った",
"set_lockscreen": "ロック画面に設定"
"set_lockscreen": "ロック画面に設定",
"maintenance_mode_message": "技術的な問題が発生しており、トラブルシューティングのために一時的にメンテナンス モードを開始しました。心配はいりません。あなたのコレクションは安全です。ただし、問題が解決され、通常の機能が回復するまで、オンチェーン トランザクションを開始することはできません。",
"maintenance_mode_header": "メンテナンスモード"

}
5 changes: 4 additions & 1 deletion wallet/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,5 +359,8 @@
"retry": "다시 해 보다",
"resolution": "해결",
"bought_nft": "구입했다",
"set_lockscreen": "잠금 화면으로 설정"
"set_lockscreen": "잠금 화면으로 설정",
"maintenance_mode_message": "기술적인 문제가 발생했으며 문제 해결을 위해 일시적으로 유지 관리 모드를 시작했습니다. 걱정하지 마세요. 컬렉션은 안전합니다. 그러나 문제를 해결하고 정상적인 기능을 복원할 때까지 온체인 트랜잭션을 시작할 수 없습니다.",
"maintenance_mode_header": "유지 관리 모드"

}
5 changes: 4 additions & 1 deletion wallet/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,8 @@
"retry": "Повторить попытку",
"bought_nft": "Купленный",
"resolution": "разрешающая способность",
"set_lockscreen": "Установить как экран блокировки"
"set_lockscreen": "Установить как экран блокировки",
"maintenance_mode_message": "У нас возникли технические проблемы, и мы временно запустили режим обслуживания для устранения неполадок. Не волнуйтесь, ваша коллекция в безопасности. Однако вы не можете инициировать транзакции в сети, пока мы не решим проблему и не восстановим нормальную работу.",
"maintenance_mode_header": "Режим технического обслуживания"

}
5 changes: 4 additions & 1 deletion wallet/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,8 @@
"retry": "Thử lại",
"resolution": "nghị quyết",
"bought_nft": "Đã mua",
"set_lockscreen": "Đặt làm màn hình khóa"
"set_lockscreen": "Đặt làm màn hình khóa",
"maintenance_mode_message": "Chúng tôi đang gặp sự cố kỹ thuật và đã tạm thời bắt đầu chế độ bảo trì để khắc phục sự cố. Đừng lo lắng, bộ sưu tập của bạn vẫn an toàn. Tuy nhiên, bạn không thể bắt đầu các giao dịch trên chuỗi cho đến khi chúng tôi giải quyết xong sự cố và khôi phục chức năng bình thường.",
"maintenance_mode_header": "Chế độ bảo trì"

}
50 changes: 50 additions & 0 deletions wallet/lib/components/maintenance_mode_widgets.dart
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),
),
);
}
}

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),
),
),
),
),
);
}
}
2 changes: 2 additions & 0 deletions wallet/lib/generated/locale_keys.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -363,5 +363,7 @@ abstract class LocaleKeys {
static const resolution = 'resolution';
static const bought_nft = 'bought_nft';
static const set_lockscreen = 'set_lockscreen';
static const maintenance_mode_message = 'maintenance_mode_message';
static const maintenance_mode_header = 'maintenance_mode_header';

}
20 changes: 19 additions & 1 deletion wallet/lib/pages/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';

class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
Expand All @@ -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();
Expand Down Expand Up @@ -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,
),
),
),
Expand Down Expand Up @@ -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);
Expand All @@ -171,6 +177,12 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi
width: 20.w,
)),
),
if (remoteConfigService.getMaintenanceMode())
Positioned(
top: 0.16.sh,
right: 0,
child: const MaintenanceModeBannerWidget(),
),
Positioned(
top: 0.2.sh - 30.r,
left: 0.5.sw - 30.r,
Expand Down Expand Up @@ -284,6 +296,12 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi
width: 20.w,
)),
),
if (remoteConfigService.getMaintenanceMode())
Positioned(
top: 0.16.sh,
right: 0,
child: const MaintenanceModeBannerWidget(),
),
Positioned(
top: 0.2.sh - 30.r,
left: 0.5.sw - 30.r,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
bool getMaintenanceMode();
}

class RemoteConfigServiceImpl implements RemoteConfigService {
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -93,6 +98,7 @@ class RemoteConfigServiceImpl implements RemoteConfigService {
chainId: dotenv.env['CHAIN_ID'],
skus: defaultPylonsSKUs,
mongoUrl: dotenv.env[mongoUrl] ?? "",
maintenanceMode: false,
});

firebaseRemoteConfig.setConfigSettings(RemoteConfigSettings(
Expand All @@ -119,4 +125,9 @@ class RemoteConfigServiceImpl implements RemoteConfigService {
String getIOSAppVersion() {
return firebaseRemoteConfig.getString(iosVERSION);
}

@override
bool getMaintenanceMode() {
return firebaseRemoteConfig.getBool(maintenanceMode);
}
}
89 changes: 89 additions & 0 deletions wallet/test/mocks/maintenance_mode_widgets_test.mocks.dart
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
Expand Up @@ -49,6 +49,7 @@ import 'package:transaction_signing_gateway/transaction_signing_gateway.dart' as
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: must_be_immutable

class _FakeEither_0<L, R> extends _i1.SmartFake implements _i2.Either<L, R> {
_FakeEither_0(
Expand Down Expand Up @@ -676,7 +677,6 @@ class MockWalletsStore extends _i1.Mock implements _i7.WalletsStore {
/// A class which mocks [AccountPublicInfo].
///
/// See the documentation for Mockito's code generation for more information.
// ignore: must_be_immutable
class MockAccountPublicInfo extends _i1.Mock implements _i6.AccountPublicInfo {
MockAccountPublicInfo() {
_i1.throwOnMissingStub(this);
Expand Down Expand Up @@ -2360,7 +2360,6 @@ class MockRepository extends _i1.Mock implements _i13.Repository {
/// A class which mocks [NFT].
///
/// See the documentation for Mockito's code generation for more information.
// ignore: must_be_immutable
class MockNFT extends _i1.Mock implements _i29.NFT {
MockNFT() {
_i1.throwOnMissingStub(this);
Expand Down
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);
});
}

0 comments on commit 72b96a1

Please sign in to comment.