chore: enable discord and github login (#3293)

This commit is contained in:
Nathan.fooo 2023-08-31 15:45:01 +08:00 committed by GitHub
parent e8f124b97c
commit 4847b8b114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 23 deletions

View File

@ -2,6 +2,7 @@ import 'package:appflowy/core/config/kv.dart';
import 'package:appflowy/core/config/kv_keys.dart'; import 'package:appflowy/core/config/kv_keys.dart';
import 'package:appflowy/core/frameless_window.dart'; import 'package:appflowy/core/frameless_window.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart'; import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/startup/startup.dart'; import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/user/application/auth/auth_service.dart'; import 'package:appflowy/user/application/auth/auth_service.dart';
import 'package:appflowy/user/application/historical_user_bloc.dart'; import 'package:appflowy/user/application/historical_user_bloc.dart';
@ -12,16 +13,15 @@ import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-error/protobuf.dart'; import 'package:appflowy_backend/protobuf/flowy-error/protobuf.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/workspace.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-folder2/workspace.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
import 'package:dartz/dartz.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/size.dart'; import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/snap_bar.dart';
import 'package:flowy_infra_ui/widget/rounded_button.dart'; import 'package:flowy_infra_ui/widget/rounded_button.dart';
import 'package:flowy_infra_ui/widget/rounded_input_field.dart'; import 'package:flowy_infra_ui/widget/rounded_input_field.dart';
import 'package:flowy_infra_ui/style_widget/snap_bar.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
class SignInScreen extends StatelessWidget { class SignInScreen extends StatelessWidget {
const SignInScreen({ const SignInScreen({
@ -430,26 +430,10 @@ class ThirdPartySignInButtons extends StatelessWidget {
mainAxisAlignment: mainAxisAlignment, mainAxisAlignment: mainAxisAlignment,
children: const [ children: const [
GoogleSignUpButton(), GoogleSignUpButton(),
// const SizedBox(width: 20), SizedBox(width: 20),
// ThirdPartySignInButton( GitHubSignUpButton(),
// icon: 'login/github-mark', SizedBox(width: 20),
// onPressed: () { DiscordSignUpButton(),
// getIt<KeyValueStorage>().set(KVKeys.loginType, 'supabase');
// context
// .read<SignInBloc>()
// .add(const SignInEvent.signedInWithOAuth('github'));
// },
// ),
// const SizedBox(width: 20),
// ThirdPartySignInButton(
// icon: 'login/discord-mark',
// onPressed: () {
// getIt<KeyValueStorage>().set(KVKeys.loginType, 'supabase');
// context
// .read<SignInBloc>()
// .add(const SignInEvent.signedInWithOAuth('discord'));
// },
// ),
], ],
); );
} }
@ -471,3 +455,37 @@ class GoogleSignUpButton extends StatelessWidget {
); );
} }
} }
class GitHubSignUpButton extends StatelessWidget {
const GitHubSignUpButton({super.key});
@override
Widget build(BuildContext context) {
return ThirdPartySignInButton(
icon: FlowySvgs.github_mark_s,
onPressed: () {
getIt<KeyValueStorage>().set(KVKeys.loginType, 'supabase');
context
.read<SignInBloc>()
.add(const SignInEvent.signedInWithOAuth('github'));
},
);
}
}
class DiscordSignUpButton extends StatelessWidget {
const DiscordSignUpButton({super.key});
@override
Widget build(BuildContext context) {
return ThirdPartySignInButton(
icon: FlowySvgs.discord_mark_s,
onPressed: () {
getIt<KeyValueStorage>().set(KVKeys.loginType, 'supabase');
context
.read<SignInBloc>()
.add(const SignInEvent.signedInWithOAuth('discord'));
},
);
}
}

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="127px" height="96px" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" xmlns:xlink="http://www.w3.org/1999/xlink">
<g><path style="opacity:0.982" fill="#5864f2" d="M 40.5,-0.5 C 42.5,-0.5 44.5,-0.5 46.5,-0.5C 46.7534,3.03777 48.5868,5.03777 52,5.5C 59.3333,4.16667 66.6667,4.16667 74,5.5C 77.4132,5.03777 79.2466,3.03777 79.5,-0.5C 81.8333,-0.5 84.1667,-0.5 86.5,-0.5C 93.6784,1.84095 100.845,4.50762 108,7.5C 117.556,21.9281 123.723,37.5947 126.5,54.5C 126.5,63.1667 126.5,71.8333 126.5,80.5C 117.234,86.2996 107.567,91.2996 97.5,95.5C 95.8333,95.5 94.1667,95.5 92.5,95.5C 90.2583,92.0205 88.2583,88.3538 86.5,84.5C 89.9621,82.9349 93.2954,81.1016 96.5,79C 95.8333,78.8333 95.1667,78.6667 94.5,78.5C 80.6757,84.0674 66.3424,85.9007 51.5,84C 44.0284,82.4993 36.6951,80.8327 29.5,79C 32.7046,81.1016 36.0379,82.9349 39.5,84.5C 37.7417,88.3538 35.7417,92.0205 33.5,95.5C 31.8333,95.5 30.1667,95.5 28.5,95.5C 18.4329,91.2996 8.76625,86.2996 -0.5,80.5C -0.5,71.8333 -0.5,63.1667 -0.5,54.5C 2.27734,37.5947 8.44401,21.9281 18,7.5C 25.419,4.30685 32.919,1.64019 40.5,-0.5 Z M 38.5,40.5 C 51.8373,41.4956 55.6706,48.1623 50,60.5C 42.3899,66.5776 36.3899,65.2442 32,56.5C 30.062,49.3891 32.2287,44.0558 38.5,40.5 Z M 80.5,40.5 C 93.8373,41.4956 97.6706,48.1623 92,60.5C 84.3899,66.5776 78.3899,65.2442 74,56.5C 72.062,49.3891 74.2287,44.0558 80.5,40.5 Z"/></g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,4 @@
<svg width="207" height="205" viewBox="0 0 207 205" fill="none" xmlns="http://www.w3.org/2000/svg">
<ellipse cx="103.5" cy="102.5" rx="103.5" ry="102.5" fill="white"/>
<path d="M102.752 16C53.1943 16 13.0083 55.0187 13.0083 103.152C13.0083 141.658 38.7225 174.327 74.3807 185.851C78.8658 186.658 80.5127 183.96 80.5127 181.658C80.5127 179.58 80.4286 172.715 80.3907 165.433C55.4239 170.704 50.1557 155.15 50.1557 155.15C46.0731 145.076 40.1907 142.397 40.1907 142.397C32.0486 136.988 40.8049 137.1 40.8049 137.1C49.8163 137.714 54.5615 146.08 54.5615 146.08C62.5662 159.404 75.5565 155.552 80.6775 153.325C81.4831 147.693 83.8087 143.847 86.3755 141.671C66.442 139.468 45.4876 131.994 45.4876 98.6005C45.4876 89.0853 48.9932 81.3105 54.734 75.2072C53.8022 73.012 50.7306 64.1484 55.6034 52.1433C55.6034 52.1433 63.1397 49.8011 80.2898 61.077C87.4482 59.1461 95.1254 58.1779 102.752 58.1445C110.379 58.1779 118.063 59.1454 125.234 61.077C142.363 49.8018 149.889 52.144 149.889 52.144C154.774 64.1478 151.701 73.0127 150.769 75.2072C156.523 81.3105 160.005 89.0853 160.005 98.6005C160.005 132.074 139.011 139.445 119.027 141.602C122.245 144.307 125.114 149.611 125.114 157.742C125.114 169.402 125.01 178.787 125.01 181.658C125.01 183.978 126.625 186.695 131.174 185.838C166.813 174.302 192.495 141.646 192.495 103.153C192.495 55.0187 152.314 16 102.752 16ZM46.6206 140.15C46.4229 140.583 45.7211 140.713 45.0824 140.415C44.431 140.132 44.0658 139.541 44.2761 139.107C44.4696 138.661 45.1728 138.536 45.8221 138.835C46.4741 139.12 46.8457 139.716 46.6206 140.15ZM51.0349 143.975C50.6072 144.36 49.7701 144.181 49.2022 143.573C48.6153 142.965 48.5052 142.152 48.9392 141.762C49.3809 141.376 50.1921 141.557 50.7804 142.164C51.3679 142.779 51.4815 143.586 51.0349 143.975ZM54.0637 148.869C53.5133 149.24 52.6145 148.892 52.0585 148.118C51.5088 147.343 51.5088 146.413 52.0704 146.041C52.6278 145.668 53.5133 146.003 54.0763 146.773C54.6246 147.561 54.6246 148.49 54.063 148.87L54.0637 148.869ZM59.1847 154.537C58.6932 155.064 57.645 154.923 56.878 154.204C56.0935 153.501 55.8754 152.504 56.369 151.977C56.8668 151.449 57.9206 151.597 58.6932 152.311C59.4714 153.012 59.7098 154.017 59.1847 154.537ZM65.8047 156.451C65.5873 157.134 64.5777 157.444 63.5618 157.154C62.5466 156.855 61.8826 156.056 62.0873 155.366C62.2984 154.678 63.3122 154.356 64.3358 154.666C65.3496 154.963 66.0157 155.756 65.8047 156.451ZM73.3375 157.263C73.3627 157.981 72.501 158.577 71.4339 158.591C70.3612 158.614 69.4925 158.032 69.4806 157.324C69.4806 156.599 70.3234 156.009 71.3968 155.991C72.4639 155.971 73.3375 156.548 73.3375 157.263ZM80.7378 156.987C80.8654 157.689 80.1243 158.409 79.0642 158.601C78.023 158.785 77.0583 158.352 76.9258 157.657C76.7968 156.938 77.5519 156.218 78.5917 156.032C79.6532 155.853 80.6025 156.274 80.7378 156.987Z" fill="#161614"/>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -0,0 +1 @@
<svg width="98" height="96" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 960 B