Skip to content

Commit

Permalink
feat: open one contact page using query param,
Browse files Browse the repository at this point in the history
replace title path on query param,
remove unused route
  • Loading branch information
ice-alcides committed Jul 31, 2024
1 parent b810d04 commit 311fc56
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ContactInputSwitcher extends StatelessWidget {
}

Future<void> selectContact(BuildContext context) async {
final contact = await ContactsSelectRoute(
final contact = await ContactsListRoute(
title: context.i18n.contacts_select_title,
).push<ContactData>(context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ import 'package:ice/app/components/list_item/list_item.dart';
import 'package:ice/app/components/screen_offset/screen_side_offset.dart';
import 'package:ice/app/extensions/extensions.dart';
import 'package:ice/app/features/wallet/providers/mock_data/contacts_mock_data.dart';
import 'package:ice/app/router/app_routes.dart';
import 'package:ice/app/router/components/navigation_app_bar/navigation_app_bar.dart';
import 'package:ice/app/router/components/navigation_app_bar/navigation_close_button.dart';
import 'package:ice/app/router/components/sheet_content/sheet_content.dart';

enum ContactRouteAction {
navigate,
pop,
}

class ContactsListView extends StatelessWidget {
const ContactsListView({super.key, required this.appBarTitle});
const ContactsListView({
super.key,
required this.appBarTitle,
required this.action,
});

final String appBarTitle;
final ContactRouteAction action;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -59,7 +70,9 @@ class ContactsListView extends StatelessWidget {
verifiedBadge: contact.isVerified!,
iceBadge: contact.hasIceAccount,
timeago: contact.lastSeen,
onTap: () => context.pop(contact),
onTap: () => action == ContactRouteAction.pop
? context.pop(contact)
: ContactRoute($extra: contact).push<void>(context),
),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ContactPage extends StatelessWidget {
onPressed: () => shareContent('Share', subject: 'Look what I found!'),
),
),
ScreenBottomOffset(),
ScreenBottomOffset(margin: 32.0.s),
],
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import 'package:ice/app/extensions/build_context.dart';
import 'package:ice/app/extensions/num.dart';
import 'package:ice/app/extensions/theme_data.dart';
import 'package:ice/app/features/wallet/model/contact_data.dart';
import 'package:ice/app/features/wallet/views/pages/coins_flow/send_coins/components/contacts_list_view.dart';
import 'package:ice/app/router/app_routes.dart';

class ContactListHeader extends StatelessWidget {
const ContactListHeader({
super.key,
});
const ContactListHeader({super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -31,11 +30,10 @@ class ContactListHeader extends StatelessWidget {
),
),
TextButton(
onPressed: () {
ContactsSelectRoute(
title: context.i18n.contacts_title,
).push<ContactData>(context);
},
onPressed: () => ContactsListRoute(
title: context.i18n.contacts_title,
action: ContactRouteAction.navigate,
).push<ContactData>(context),
child: Padding(
padding: EdgeInsets.all(UiConstants.hitSlop),
child: Text(
Expand Down
22 changes: 8 additions & 14 deletions lib/app/router/wallet_routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class WalletRoutes {
TypedGoRoute<CoinsSendFormRoute>(
path: 'coin-send-form',
routes: [
TypedGoRoute<ContactsSelectRoute>(path: 'contacts-select/:title'),
TypedGoRoute<ContactsListRoute>(path: 'contacts-list'),
],
),
TypedGoRoute<CoinsSendFormConfirmationRoute>(
Expand Down Expand Up @@ -187,14 +187,18 @@ class CoinsSendFormRoute extends BaseRouteData {
);
}

class ContactsSelectRoute extends BaseRouteData {
ContactsSelectRoute({required this.title})
class ContactsListRoute extends BaseRouteData {
ContactsListRoute({required this.title, this.action = ContactRouteAction.pop})
: super(
child: ContactsListView(appBarTitle: title),
child: ContactsListView(
appBarTitle: title,
action: action,
),
type: IceRouteType.bottomSheet,
);

final String title;
final ContactRouteAction action;
}

class CoinsSendFormConfirmationRoute extends BaseRouteData {
Expand Down Expand Up @@ -319,16 +323,6 @@ class ContactRoute extends BaseRouteData {
final ContactData $extra;
}

class ContactReceiveRoute extends BaseRouteData {
ContactReceiveRoute({required this.$extra})
: super(
child: ContactPage(contactData: $extra),
type: IceRouteType.bottomSheet,
);

final ContactData $extra;
}

class NftDetailsRoute extends BaseRouteData {
NftDetailsRoute({required this.$extra})
: super(
Expand Down

0 comments on commit 311fc56

Please sign in to comment.