Skip to content
Draft
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
9 changes: 7 additions & 2 deletions example/lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ FontWeight kFwMedium = FontWeight.w500;
FontWeight kFwBlack = FontWeight.w900;

TextStyle kTitleText = kRobotoText.copyWith(
fontWeight: kFwMedium, color: Colors.black, fontSize: kTitle);
fontWeight: kFwMedium,
color: Colors.black,
fontSize: kTitle,
);

// Vertical Spacing
Widget get verticalSpaceSmall => SizedBox(height: 8.0.h);
Expand All @@ -31,7 +34,9 @@ Widget get verticalSpaceMedium => SizedBox(height: 24.0.h);

//Box Decoration
BoxDecoration roundedBoxRegular = BoxDecoration(
color: Colors.black, borderRadius: BorderRadius.all(Radius.circular(16.r)));
color: Colors.black,
borderRadius: BorderRadius.all(Radius.circular(16.r)),
);

//color
const kColorGrey = Color(0xFF676767);
10 changes: 3 additions & 7 deletions example/lib/encrypted_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ class EncryptedBox {
static Future<void> init() async {
_instance = EncryptedBox._privateConstructor();
_instance!._secureStorage = const FlutterSecureStorage(
aOptions: AndroidOptions(
encryptedSharedPreferences: true,
),
iOptions: IOSOptions(
accessibility: KeychainAccessibility.first_unlock,
),
aOptions: AndroidOptions(encryptedSharedPreferences: true),
iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock),
webOptions: WebOptions(
dbName: 'app_secure_storage',
publicKey: 'app_public_key',
Expand Down Expand Up @@ -88,4 +84,4 @@ class EncryptedBox {
debugPrint("clear() failed: ${e.toString()}");
}
}
}
}
30 changes: 15 additions & 15 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ void main() async {
usePathUrlStrategy();
await dotenv.load(fileName: ".env");
await KindeFlutterSDK.initializeSDK(
authDomain: dotenv.env['KINDE_AUTH_DOMAIN']!,
authClientId: dotenv.env['KINDE_AUTH_CLIENT_ID']!,
loginRedirectUri: dotenv.env['KINDE_LOGIN_REDIRECT_URI']!,
logoutRedirectUri: dotenv.env['KINDE_LOGOUT_REDIRECT_URI']!,
scopes: ["email", "profile", "offline", "openid"] // optional
);
authDomain: dotenv.env['KINDE_AUTH_DOMAIN']!,
authClientId: dotenv.env['KINDE_AUTH_CLIENT_ID']!,
loginRedirectUri: dotenv.env['KINDE_LOGIN_REDIRECT_URI']!,
logoutRedirectUri: dotenv.env['KINDE_LOGOUT_REDIRECT_URI']!,
scopes: ["email", "profile", "offline", "openid"], // optional
);

await EncryptedBox.init();
runApp(const MyApp());
Expand Down Expand Up @@ -52,15 +52,15 @@ class _MyAppState extends State<MyApp> {
if (kIsWeb) return;
_userStreamSubscription = AppStateManager.instance.userProfileStream.stream
.listen((userProfileChanges) {
final oldUser = userProfileChanges.$1;
final newUser = userProfileChanges.$2;
if (oldUser == null && newUser != null) {
_navigateToHome();
}
if (oldUser != null && newUser == null) {
_navigateToWelcome();
}
});
final oldUser = userProfileChanges.$1;
final newUser = userProfileChanges.$2;
if (oldUser == null && newUser != null) {
_navigateToHome();
}
if (oldUser != null && newUser == null) {
_navigateToWelcome();
}
});
}

void _navigateToHome() {
Expand Down
47 changes: 25 additions & 22 deletions example/lib/navigation/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,29 @@ import '../screens/home/home_screen.dart';
import '../screens/routes.dart';

GoRouter createRouter() => GoRouter(
debugLogDiagnostics: kDebugMode,
initialLocation: AppRoutes.SPLASH,
errorBuilder: (context, state) {
return const UnknownScreen();
debugLogDiagnostics: kDebugMode,
initialLocation: AppRoutes.SPLASH,
errorBuilder: (context, state) {
return const UnknownScreen();
},
routes: [
GoRoute(
path: AppRoutes.HOME,
builder: (context, state) {
return const HomeScreen();
},
routes: [
GoRoute(
path: AppRoutes.HOME,
builder: (context, state) {
return const HomeScreen();
}),
GoRoute(
path: AppRoutes.SPLASH,
builder: (context, state) {
return const SplashScreen();
}),
GoRoute(
path: AppRoutes.WELCOME,
builder: (context, state) {
return const WelcomeScreen();
}),
],
);
),
GoRoute(
path: AppRoutes.SPLASH,
builder: (context, state) {
return const SplashScreen();
},
),
GoRoute(
path: AppRoutes.WELCOME,
builder: (context, state) {
return const WelcomeScreen();
},
),
],
);
99 changes: 50 additions & 49 deletions example/lib/screens/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ class _HomeScreenState extends State<HomeScreen> {
extendBodyBehindAppBar: true,
body: Padding(
padding: EdgeInsets.only(
top: MediaQuery.viewPaddingOf(context).top,
left: 16.w,
right: 16.w,
bottom: MediaQuery.viewPaddingOf(context).bottom),
top: MediaQuery.viewPaddingOf(context).top,
left: 16.w,
right: 16.w,
bottom: MediaQuery.viewPaddingOf(context).bottom,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expand All @@ -58,8 +59,7 @@ class _HomeScreenState extends State<HomeScreen> {
SchedulerBinding.instance.addPostFrameCallback((_) {
context.pushReplacement(AppRoutes.WELCOME);
});
return const SizedBox
.shrink(); // Return empty widget while navigating
return const SizedBox.shrink(); // Return empty widget while navigating
} else {
return Text(
'${user.givenName} ${user.familyName}',
Expand All @@ -69,61 +69,62 @@ class _HomeScreenState extends State<HomeScreen> {
}
}
return const Center(
child: CircularProgressIndicator.adaptive());
child: CircularProgressIndicator.adaptive(),
);
},
),
const SizedBox(height: 10),
InkWell(
onTap: AppStateManager.instance.signOut,
child: const Text('Sign out')),
onTap: AppStateManager.instance.signOut,
child: const Text('Sign out'),
),
],
),
),
Expanded(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
verticalSpaceMedium,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: double.infinity,
padding: EdgeInsets.all(32.w),
decoration: roundedBoxRegular,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
verticalSpaceMedium,
Text(
"Woohoo!",
textAlign: TextAlign.center,
style: kTitleText.copyWith(color: Colors.white),
),
verticalSpaceMedium,
Text(
"Your\nauthentication is\nall sorted.\nBuild the\nimportant stuff.",
textAlign: TextAlign.center,
style: kRobotoText.copyWith(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
verticalSpaceMedium,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: double.infinity,
padding: EdgeInsets.all(32.w),
decoration: roundedBoxRegular,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
verticalSpaceMedium,
Text(
"Woohoo!",
textAlign: TextAlign.center,
style: kTitleText.copyWith(color: Colors.white),
),
verticalSpaceMedium,
Text(
"Your\nauthentication is\nall sorted.\nBuild the\nimportant stuff.",
textAlign: TextAlign.center,
style: kRobotoText.copyWith(
fontWeight: kFwBlack,
color: Colors.white,
fontSize: kTitleLarge),
),
],
fontSize: kTitleLarge,
),
),
],
),
),
),
verticalSpaceRegular,
Text(
"Next steps for you",
style: kTitleText,
),
],
),
const PageFooter(),
],
verticalSpaceRegular,
Text("Next steps for you", style: kTitleText),
],
),
const PageFooter(),
],
),
),
))
),
],
),
),
Expand Down
35 changes: 18 additions & 17 deletions example/lib/screens/splash/splash_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@ class _SplashScreenState extends State<SplashScreen> {
backgroundColor: Colors.white,
extendBodyBehindAppBar: true,
body: FutureBuilder(
future: future,
builder: (context, asyncSnapshot) {
if (asyncSnapshot.connectionState == ConnectionState.done) {
final user = asyncSnapshot.data;
final route = user == null ? AppRoutes.WELCOME : AppRoutes.HOME;
SchedulerBinding.instance.addPostFrameCallback((_) {
context.pushReplacement(route);
});
}
return Center(
child: Text(
"K",
style: TextStyle(fontSize: 48.h, color: Colors.black),
textAlign: TextAlign.center,
),
);
}),
future: future,
builder: (context, asyncSnapshot) {
if (asyncSnapshot.connectionState == ConnectionState.done) {
final user = asyncSnapshot.data;
final route = user == null ? AppRoutes.WELCOME : AppRoutes.HOME;
SchedulerBinding.instance.addPostFrameCallback((_) {
context.pushReplacement(route);
});
}
return Center(
child: Text(
"K",
style: TextStyle(fontSize: 48.h, color: Colors.black),
textAlign: TextAlign.center,
),
);
},
),
);
}
}
4 changes: 1 addition & 3 deletions example/lib/screens/unknown/unknown_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ class UnknownScreen extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Unknown Page')),
body: const Center(
child: Text('404 - Page not found'),
),
body: const Center(child: Text('404 - Page not found')),
);
}
}
Loading