Skip to content

Commit

Permalink
otpauth url テスト
Browse files Browse the repository at this point in the history
  • Loading branch information
narumincho committed Jan 13, 2024
1 parent 7eb463f commit bbda7db
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 42 deletions.
93 changes: 52 additions & 41 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,63 +25,74 @@ class _DefinyAppState extends State<DefinyApp> {

@override
Widget build(BuildContext context) {
return DefinyAppPresentation(
logInState: _logInState,
return MaterialApp(
title: 'definy',
onGenerateTitle: (context) {
print('onGenerateTitle');
return switch (_logInState) {
LogInStateNotLoggedIn() => 'top - definy',
LogInStateLoading() => 'アカウント - definy'
};
},
onGenerateRoute: (settings) => MaterialPageRoute(
builder: (context) => DefinyAppPresentation(
logInState: _logInState,
routeSettings: settings,
),
),
);
}
}

class DefinyAppPresentation extends StatelessWidget {
const DefinyAppPresentation({required this.logInState, super.key});
const DefinyAppPresentation({
required this.logInState,
required this.routeSettings,
super.key,
});

final LogInState logInState;
final RouteSettings routeSettings;

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'definy',
key: Key(logInState.toString()),
onGenerateTitle: (context) {
print('onGenerateTitle');
return switch (logInState) {
LogInStateNotLoggedIn() => 'definy',
LogInStateLoading() => 'アカウント - definy'
};
},
onGenerateRoute: (settings) => MaterialPageRoute(
builder: (context) => Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xff333333),
title: const SelectableText(
return Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xff333333),
title: Link(
uri: Uri.parse('/'),
builder: (context, followLink) => TextButton(
onPressed: followLink,
child: const Text(
'definy',
style: TextStyle(color: Color(0xffb9d09b)),
),
actions: [
Link(
uri: Uri.parse('/account'),
builder: (context, followLink) => switch (logInState) {
LogInStateNotLoggedIn() => TextButton(
onPressed: followLink,
child: const Text(
'ゲスト',
style: TextStyle(color: Colors.white),
),
),
LogInStateLoading() => IconButton(
onPressed: followLink,
icon: const CircularProgressIndicator(),
),
},
),
],
),
body: settings.name == '/account'
? AccountPage(logInState: logInState)
: Center(
child: SelectableText('いろいろ表示したい $settings'),
),
),
actions: [
Link(
uri: Uri.parse('/account'),
builder: (context, followLink) => switch (logInState) {
LogInStateNotLoggedIn() => TextButton(
onPressed: followLink,
child: const Text(
'ゲスト',
style: TextStyle(color: Colors.white),
),
),
LogInStateLoading() => IconButton(
onPressed: followLink,
icon: const CircularProgressIndicator(),
),
},
),
],
),
body: routeSettings.name == '/account'
? AccountPage(logInState: logInState)
: Center(
child: SelectableText('いろいろ表示したい $routeSettings'),
),
);
}
}
25 changes: 24 additions & 1 deletion lib/page/account.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:definy/model/log_in_state.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/link.dart';

class AccountPage extends StatelessWidget {
final LogInState logInState;
Expand All @@ -11,7 +12,29 @@ class AccountPage extends StatelessWidget {
return Column(
children: [
const Text('アカウントページ'),
Text(logInState.toString()),
...switch (logInState) {
LogInStateLoading() => [const Text('ログイン状態を確認中...')],
LogInStateNotLoggedIn() => [
const Text('ログインしていません'),
ElevatedButton(
onPressed: () {},
child: const Text('ログイン'),
),
ElevatedButton(
onPressed: () {},
child: const Text('新規登録'),
),
Link(
uri: Uri.parse(
'otpauth://totp/Example:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Example',
),
builder: (context, followLink) => TextButton(
onPressed: followLink,
child: const Text('otpauth url テスト'),
),
)
],
},
],
);
}
Expand Down

0 comments on commit bbda7db

Please sign in to comment.