Skip to content

Commit

Permalink
Merge pull request #707 from CyBear-Jinni/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
guyluz11 authored Dec 29, 2023
2 parents 06cee29 + 541ef5e commit a96b42a
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 16 deletions.
1 change: 1 addition & 0 deletions lib/presentation/atoms/atoms.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export 'bottom_navigation_bar_item_atom.dart';
export 'button_atom.dart';
export 'circular_progress_indicator_atom.dart';
export 'image_atom.dart';
export 'margined_expanded_atom.dart';
Expand Down
69 changes: 69 additions & 0 deletions lib/presentation/atoms/button_atom.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:cybear_jinni/presentation/atoms/atoms.dart';
import 'package:flutter/material.dart';

class ButtonWidgetAtom extends StatelessWidget {
const ButtonWidgetAtom({
required this.variant,
required this.onPressed,
super.key,
this.text,
this.icon,
this.disabled = false,
this.disableActionType = false,
this.translate = true,
});

final ButtonVariant variant;
final VoidCallback onPressed;
final String? text;
final IconData? icon;
double get width => 250;
double get _height => 60;
final bool disabled;
final bool translate;
final bool disableActionType;

@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
final TextTheme textTheme = themeData.textTheme;
final ColorScheme colorScheme = themeData.colorScheme;

if (variant == ButtonVariant.primary) {
return Container(
constraints: const BoxConstraints(
minWidth: 300,
),
height: _height,
child: FilledButton.icon(
onPressed: onPressed,
style: FilledButton.styleFrom().copyWith(
alignment: Alignment.center,
backgroundColor: disabled
? MaterialStateProperty.all(colorScheme.surfaceVariant)
: null,
),
icon: Icon(icon),
label: TextAtom(
text ?? '',
translate: translate,
maxLines: 1,
style: textTheme.bodyLarge!.copyWith(
color: colorScheme.onPrimary,
),
),
),
);
}
return const Text('Type is not supported yet');
}
}

enum ButtonVariant {
primary,
secondary,
tertiary,
action,
actionToggled,
back,
}
85 changes: 69 additions & 16 deletions lib/presentation/pages/splash_page.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import 'dart:io';

import 'package:auto_route/auto_route.dart';
import 'package:cybear_jinni/domain/i_local_db_repository.dart';
import 'package:cybear_jinni/presentation/atoms/atoms.dart';
import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

@RoutePage()
class SplashPage extends StatefulWidget {
Expand All @@ -18,21 +14,32 @@ class _SplashPageState extends State<SplashPage> {
void initState() {
super.initState();

_navigate();
// _navigate();
openUpdateDialog();
}

Future _navigate() async {
(await ILocalDbRepository.instance.getHubEntityNetworkName()).fold(
(l) {
if (kIsWeb || Platform.isLinux || Platform.isWindows) {
return context.router.replace(const ConnectToHubRoute());
}
return context.router.replace(const IntroductionRouteRoute());
},
(r) => context.router.replace(const HomeRoute()),
);
Future openUpdateDialog() async {
await Future.delayed(const Duration(seconds: 1));
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => UpdateDialog(),
);
}
}

// Future _navigate() async {
// (await ILocalDbRepository.instance.getHubEntityNetworkName()).fold(
// (l) {
// if (kIsWeb || Platform.isLinux || Platform.isWindows) {
// return context.router.replace(const ConnectToHubRoute());
// }
// return context.router.replace(const IntroductionRouteRoute());
// },
// (r) => context.router.replace(const HomeRoute()),
// );
// }

@override
Widget build(BuildContext context) {
return const Scaffold(
Expand All @@ -44,3 +51,49 @@ class _SplashPageState extends State<SplashPage> {
);
}
}

class UpdateDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
final TextTheme textTheme = themeData.textTheme;
final ColorScheme colorScheme = themeData.colorScheme;

return Center(
child: AlertDialog(
title: TextAtom('A New App', style: textTheme.titleLarge),
content: SizedBox(
height: 170,
child: Column(
children: [
TextAtom(
'We have moved to a new app.\n'
'Please download the new app and delete this one.\n'
'See you in the other side :D',
style: textTheme.titleMedium,
),
const Expanded(
child: SizedBox(),
),
ElevatedButton(
child: TextAtom(
'Download',
style: textTheme.titleMedium,
),
onPressed: () {
launchUrl(
Uri.parse(
'https://play.google.com/store/apps/details?id=com.cybearjinni.app',
),
mode: LaunchMode.externalApplication,
);
},
),
],
),
),
actions: [],
),
);
}
}

0 comments on commit a96b42a

Please sign in to comment.