Skip to content
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

리딤코드 등록/사용내역 웹뷰로 띄움 #2505

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/mobile/lib/routers/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class AppRouter extends $AppRouter {
AutoRoute(page: MeRoute.page, path: 'me'),
],
),
AutoRoute(page: RedeemRoute.page),
AutoRoute(page: DeactivateRoute.page),
AutoRoute(
page: EditorRoute.page,
Expand Down
6 changes: 5 additions & 1 deletion apps/mobile/lib/screens/me.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ class _MeScreenState extends ConsumerState<MeScreen> {
_MenuItem(
icon: Tabler.scan,
title: '리딤코드',
onPressed: () {},
onPressed: () async {
await context.router.push(
const RedeemRoute(),
);
},
),
],
),
Expand Down
35 changes: 35 additions & 0 deletions apps/mobile/lib/screens/redeem.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:glyph/components/heading.dart';
import 'package:glyph/components/webview.dart';
import 'package:glyph/routers/app.gr.dart';

@RoutePage()
class RedeemScreen extends StatelessWidget {
const RedeemScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const Heading(
title: Text(
'리딤코드',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w700,
),
),
),
body: WebView(
path: '/me/redeem',
onJsMessage: (data, reply) async {
if (data['type'] == 'post:view') {
await context.router.push(
PostRoute(permalink: data['permalink']),
);
}
},
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import IconCoin from '~icons/tabler/coin';
import { graphql } from '$glitch';
import { Helmet, Icon, Image } from '$lib/components';
import { isWebView, postFlutterMessage } from '$lib/flutter';
import { comma } from '$lib/utils';
import { css } from '$styled-system/css';
import { flex } from '$styled-system/patterns';
Expand Down Expand Up @@ -73,9 +74,19 @@
paddingY: { base: '15px', sm: '14px' },
})}
>
<a
<svelte:element
this={$isWebView ? 'button' : 'a'}
class={flex({ align: 'center', justify: 'space-between', width: 'full', truncate: true })}
href={`/${redemption.postPurchase.post.space.slug}/${redemption.postPurchase.post.permalink}`}
href={$isWebView
? undefined
: `/${redemption.postPurchase.post.space.slug}/${redemption.postPurchase.post.permalink}`}
role={$isWebView ? 'button' : 'a'}
on:click={() => {
if ($isWebView) {
postFlutterMessage({ type: 'post:view', permalink: redemption.postPurchase.post.permalink });
return;
}
}}
>
<div class={flex({ align: 'center', gap: { base: '8px', sm: '12px' }, width: 'full', truncate: true })}>
<Image
Expand Down Expand Up @@ -115,7 +126,7 @@
</div>
</div>
<Icon style={css.raw({ color: 'gray.400', hideBelow: 'sm' })} icon={IconChevronRight} size={24} />
</a>
</svelte:element>
<hr
class={css({ marginY: '16px', border: 'none', width: 'full', height: '1px', backgroundColor: 'gray.100' })}
/>
Expand Down
Loading