Skip to content

Commit

Permalink
fix: revert back the appEnv and change the comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrar-deriv committed Nov 20, 2023
1 parent 517c775 commit d354d0d
Showing 1 changed file with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class DerivSettingLayout extends StatefulWidget {
this.appId = defaultAppId,
this.devApp = 'com.deriv.app.dev',
this.stagingApp = 'com.deriv.app.staging',
this.getAppEnv,
this.setAppEnv,
Key? key,
}) : super(key: key);

Expand All @@ -44,6 +46,12 @@ class DerivSettingLayout extends StatefulWidget {
/// Staging flavor app.
final String stagingApp;

/// Gets environment variable
final Future<bool>? getAppEnv;

/// Sets environment variable
final Future<void> Function({required bool value})? setAppEnv;

@override
_SettingsPageState createState() => _SettingsPageState();
}
Expand Down Expand Up @@ -109,12 +117,29 @@ class _SettingsPageState extends State<DerivSettingLayout> {
if (snapshot.hasData &&
(snapshot.data?.packageName == widget.devApp ||
snapshot.data?.packageName == widget.stagingApp)) {
return const Padding(
padding: EdgeInsets.symmetric(horizontal: ThemeProvider.margin16),
return Padding(
padding:
const EdgeInsets.symmetric(horizontal: ThemeProvider.margin16),
child: Row(
children: <Widget>[
Text('Production environment'),
SizedBox(width: ThemeProvider.margin08),
const Text('Production environment'),
const SizedBox(width: ThemeProvider.margin08),
FutureBuilder<bool>(
future: widget.getAppEnv,
builder:
(BuildContext context, AsyncSnapshot<bool?> snapshot) {
if (snapshot.hasData && widget.setAppEnv != null) {
return Switch(
value: snapshot.data ?? false,
onChanged: (bool val) {
setState(() {
widget.setAppEnv!(value: val);
});
},
);
}
return const SizedBox.shrink();
})
],
),
);
Expand Down

0 comments on commit d354d0d

Please sign in to comment.