Skip to content

Commit

Permalink
Merge pull request #1114 from get10101/chore/page-transitions
Browse files Browse the repository at this point in the history
chore: merge settings screen and fix transition direction
  • Loading branch information
klochowicz authored Aug 18, 2023
2 parents 873fd0b + 4d163b2 commit a4005f5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 57 deletions.
25 changes: 21 additions & 4 deletions mobile/lib/common/app_bar_wrapper.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get_10101/common/color.dart';
import 'package:get_10101/features/trade/settings_screen.dart';
import 'package:get_10101/common/settings_screen.dart';
import 'package:get_10101/features/trade/trade_screen.dart';
import 'package:get_10101/features/wallet/settings_screen.dart';
import 'package:get_10101/features/wallet/wallet_screen.dart';
import 'package:get_10101/features/wallet/status_screen.dart';
import 'package:go_router/go_router.dart';
Expand Down Expand Up @@ -35,7 +34,7 @@ class AppBarWrapper extends StatelessWidget {
icon: const Icon(Icons.settings),
tooltip: 'Settings',
onPressed: () {
context.go(WalletSettingsScreen.route);
Navigator.of(context).push(_createRoute());
},
)
]);
Expand All @@ -47,7 +46,7 @@ class AppBarWrapper extends StatelessWidget {
icon: const Icon(Icons.settings),
tooltip: 'Settings',
onPressed: () {
context.go(TradeSettingsScreen.route);
Navigator.of(context).push(_createRoute());
},
)
]);
Expand All @@ -71,3 +70,21 @@ class AppBarWrapper extends StatelessWidget {
));
}
}

Route _createRoute() {
return PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) => const SettingsScreen(),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
const begin = Offset(-1.0, 0.0);
const end = Offset.zero;
const curve = Curves.ease;

var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));

return SlideTransition(
position: animation.drive(tween),
child: child,
);
},
);
}
19 changes: 2 additions & 17 deletions mobile/lib/common/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import 'package:feedback/feedback.dart';
import 'package:flutter/material.dart';
import 'package:get_10101/common/feedback.dart';
import 'package:get_10101/common/scrollable_safe_area.dart';
import 'package:get_10101/features/trade/settings_screen.dart';
import 'package:get_10101/features/wallet/settings_screen.dart';
import 'package:get_10101/bridge_generated/bridge_definitions.dart' as bridge;
import 'package:intl/intl.dart';
import 'package:path_provider/path_provider.dart';
Expand All @@ -17,9 +15,9 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'package:get_10101/ffi.dart' as rust;

class SettingsScreen extends StatefulWidget {
const SettingsScreen({required this.fromRoute, super.key});
static const subRouteName = "settings";

final String fromRoute;
const SettingsScreen({super.key});

@override
State<SettingsScreen> createState() => _SettingsScreenState();
Expand Down Expand Up @@ -59,13 +57,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
appBar: AppBar(title: const Text("Settings")),
body: ScrollableSafeArea(
child: Column(children: [
Text(
"Wallet Settings",
style: TextStyle(
fontWeight: widget.fromRoute == WalletSettingsScreen.route
? FontWeight.bold
: FontWeight.normal),
),
Visibility(
visible: config.network == "regtest",
child: Column(
Expand All @@ -84,12 +75,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
),
),
const Divider(),
Text("Trade Settings",
style: TextStyle(
fontWeight: widget.fromRoute == TradeSettingsScreen.route
? FontWeight.bold
: FontWeight.normal)),
const Divider(),
const Text("App Info"),
Table(
border: TableBorder.symmetric(inside: const BorderSide(width: 1)),
Expand Down
15 changes: 0 additions & 15 deletions mobile/lib/features/trade/settings_screen.dart

This file was deleted.

15 changes: 0 additions & 15 deletions mobile/lib/features/wallet/settings_screen.dart

This file was deleted.

12 changes: 6 additions & 6 deletions mobile/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import 'package:get_10101/features/trade/position_change_notifier.dart';
import 'package:get_10101/features/trade/status_screen.dart';
import 'package:get_10101/features/trade/submit_order_change_notifier.dart';
import 'package:get_10101/features/trade/trade_value_change_notifier.dart';
import 'package:get_10101/features/trade/settings_screen.dart';
import 'package:get_10101/features/trade/trade_theme.dart';
import 'package:get_10101/features/wallet/application/wallet_service.dart';
import 'package:get_10101/features/wallet/create_invoice_screen.dart';
Expand All @@ -37,7 +36,6 @@ import 'package:get_10101/features/wallet/send_payment_change_notifier.dart';
import 'package:get_10101/features/wallet/share_invoice_screen.dart';
import 'package:get_10101/features/wallet/scanner_screen.dart';
import 'package:get_10101/features/wallet/send_screen.dart';
import 'package:get_10101/features/wallet/settings_screen.dart';
import 'package:get_10101/features/trade/trade_screen.dart';
import 'package:get_10101/features/wallet/status_screen.dart';
import 'package:get_10101/features/wallet/wallet_change_notifier.dart';
Expand All @@ -59,6 +57,8 @@ import 'package:get_10101/features/wallet/domain/wallet_info.dart';
import 'package:get_10101/ffi.dart' as rust;
import 'package:version/version.dart';

import 'common/settings_screen.dart';

final GlobalKey<NavigatorState> _rootNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'root');
final GlobalKey<NavigatorState> _shellNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'shell');

Expand Down Expand Up @@ -177,10 +177,10 @@ class _TenTenOneAppState extends State<TenTenOneApp> {
},
),
GoRoute(
path: WalletSettingsScreen.subRouteName,
path: SettingsScreen.subRouteName,
parentNavigatorKey: _rootNavigatorKey,
builder: (BuildContext context, GoRouterState state) {
return const WalletSettingsScreen();
return const SettingsScreen();
}),
GoRoute(
path: WalletStatusScreen.subRouteName,
Expand All @@ -197,10 +197,10 @@ class _TenTenOneAppState extends State<TenTenOneApp> {
},
routes: <RouteBase>[
GoRoute(
path: TradeSettingsScreen.subRouteName,
path: SettingsScreen.subRouteName,
parentNavigatorKey: _rootNavigatorKey,
builder: (BuildContext context, GoRouterState state) {
return const TradeSettingsScreen();
return const SettingsScreen();
}),
GoRoute(
path: TradeStatusScreen.subRouteName,
Expand Down

0 comments on commit a4005f5

Please sign in to comment.