Skip to content

Commit

Permalink
Desktop slider (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
shareef-dweikat authored Jun 7, 2022
1 parent 0607b40 commit 9fe1c43
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 25 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
Expand Down
Binary file modified assets/images/Device2Device.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/Laptop-to-mobile-transfer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/No-Sign-Up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/icons/WHITE-ARROW.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/intro-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/config/routes/routes.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const String HOME_ROUTE = '/home';
const String INTRO_ROUTE = '/intro';
const String SEND_ROUTE = '/send';
const String DESKTOP_SEND_ROUTE = '/';
const String DESKTOP_SEND_ROUTE = '/desktop_send_route';
const String RECEIVE_ROUTE = '/receive';
const String SPLASH_ROUTE = '/';
const String SETTINGS_ROUTE = '/settings';
12 changes: 12 additions & 0 deletions lib/config/routes/routes_desktop_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@ import 'package:dart_wormhole_gui/views/desktop/settings.dart';
import 'package:dart_wormhole_william/client/native_client.dart';
import 'package:flutter/cupertino.dart';

import '../../views/desktop/introduction-slider.dart';
import '../../views/desktop/splash.dart';

PageRouteBuilder? Function(RouteSettings) getDesktopRoutes(Config config) {
return (RouteSettings settings) {
switch (settings.name) {
case SPLASH_ROUTE:
{
return PageRouteBuilder(pageBuilder: (_, __, ___) => Splash());
}
case INTRO_ROUTE:
{
return PageRouteBuilder(
pageBuilder: (_, __, ___) => IntroScreen(config));
}
case DESKTOP_SEND_ROUTE:
{
return PageRouteBuilder(pageBuilder: (_, __, ___) => SendScreen());
Expand Down
1 change: 1 addition & 0 deletions lib/constants/asset_path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const String LOGO = 'assets/images/logo.png';
const String DEVICE_TO_DEVICE_IMG = 'assets/images/Device2Device.png';
const String PRIVACY_IMG = 'assets/images/No-Sign-Up.png';
const String INTRO_LOGO = 'assets/images/intro-logo.png';
const String LAPTOP_TO_MOBILE = 'assets/images/Laptop-to-mobile-transfer.png';

//Icons
const String SEND_ICON = 'assets/images/icons/send.png';
Expand Down
107 changes: 107 additions & 0 deletions lib/views/desktop/introduction-slider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import 'package:dart_wormhole_gui/constants/app_constants.dart';
import 'package:dart_wormhole_gui/constants/asset_path.dart';
import 'package:dart_wormhole_gui/views/desktop/send/send.dart';
import 'package:dart_wormhole_william/client/native_client.dart';
import 'package:flutter/material.dart';
import 'package:intro_slider/intro_slider.dart';
import 'package:intro_slider/scrollbar_behavior_enum.dart';
import 'package:intro_slider/slide_object.dart';
import 'package:shared_preferences/shared_preferences.dart';

class IntroScreen extends StatefulWidget {
final Config config;
IntroScreen(this.config);

@override
IntroScreenState createState() => new IntroScreenState(config);
}

// ------------------ Custom config ------------------
class IntroScreenState extends State<IntroScreen> {
final Config config;
IntroScreenState(this.config);

List<Slide> slides = [];

@override
void initState() {
super.initState();
slides.add(
new Slide(
title: END_TO_END_ENCRYPTION,
titleTextFontSize: 44.0,
subTitleTextFontSize: 24.0,
desktopActionButtonEnabled: true,
description:
SEND_AND_RECEIVE_FILES_SECURELY_WITH_SIMPLICITY_AND_SPEED,
btnTitle: GET_STARTED,
pathImage: INTRO_LOGO,
backgroundColor: Colors.black,
heightImage: 300.0),
);
slides.add(
new Slide(
title: NO_SIGN_UP,
titleTextFontSize: 44.0,
subTitleTextFontSize: 24.0,
desktopActionButtonEnabled: true,
description: SEND_AND_RECEIVE_FILES_WITH_NO_NEED_TO_SIGN_UP,
pathImage: PRIVACY_IMG,
backgroundColor: Colors.black,
btnTitle: NEXT,
heightImage: 300.0),
);
slides.add(
new Slide(
title: DEVICE_TO_DEVICE,
titleTextFontSize: 44.0,
subTitleTextFontSize: 24.0,
desktopActionButtonEnabled: true,
description: SEND_AND_RECEIVE_FROM_AND_TO_YOUR_DEVICE_WITHOUT_STORING,
btnTitle: START_HERE,
maxLineTextDescription: 3,
pathImage: LAPTOP_TO_MOBILE,
backgroundColor: Colors.black,
heightImage: 300.0),
);
}

Future setSeenToTrue() async {
SharedPreferences? prefs = await SharedPreferences.getInstance();
return prefs.setBool(SEEN, true);
}

void onDonePress() async {
await setSeenToTrue();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SendScreen()),
);
}

ButtonStyle myButtonStyle() {
return ButtonStyle(
shape: MaterialStateProperty.all<OutlinedBorder>(StadiumBorder()),
backgroundColor: MaterialStateProperty.all<Color>(Color(0x33F3B4BA)),
overlayColor: MaterialStateProperty.all<Color>(Color(0x33FFA8B0)),
);
}

@override
Widget build(BuildContext context) {
return new IntroSlider(
slides: this.slides,
showSkipBtn: false,
showNextBtn: false,
showPrevBtn: false,
showDoneBtn: false,
onDonePress: this.onDonePress,
colorDot: Theme.of(context).scaffoldBackgroundColor,
colorActiveDot: Theme.of(context).colorScheme.secondary,
sizeDot: 13.0,
hideStatusBar: false,
backgroundColorAllSlides: Colors.grey,
verticalScrollbarBehavior: scrollbarBehavior.SHOW_ALWAYS,
);
}
}
40 changes: 40 additions & 0 deletions lib/views/desktop/splash.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:dart_wormhole_gui/config/routes/routes.dart';
import 'package:dart_wormhole_gui/constants/app_constants.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';

class Splash extends StatelessWidget {
SharedPreferences? prefs;
Future isItAppFirstLunch() async {
prefs = await SharedPreferences.getInstance();
bool _seen = (prefs?.getBool(SEEN) ?? false);
return _seen;
}

Future setSeenToTrue() async {
return prefs?.setBool(SEEN, true);
}

Future checkFirstSeen(context) async {
bool isItFirstLunch = await isItAppFirstLunch();
if (isItFirstLunch) {
Navigator.pushNamed(context, DESKTOP_SEND_ROUTE);
} else {
Navigator.pushNamed(context, INTRO_ROUTE);
}
}

@override
Widget build(BuildContext context) {
checkFirstSeen(context);
return Scaffold(
body: Center(
key: Key(SPLASH_SCREEN_BODY),
child: Text(
LOADING,
key: Key(SPLASH_SCREEN_LOADING),
),
),
);
}
}
9 changes: 6 additions & 3 deletions lib/views/mobile/introduction-slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class IntroScreenState extends State<IntroScreen> {
title: END_TO_END_ENCRYPTION,
description:
SEND_AND_RECEIVE_FILES_SECURELY_WITH_SIMPLICITY_AND_SPEED,
subTitleTextFontSize: 14.0,
titleTextFontSize: 23.0,
btnTitle: GET_STARTED,
pathImage: INTRO_LOGO,
backgroundColor: Colors.black,
Expand All @@ -40,6 +42,8 @@ class IntroScreenState extends State<IntroScreen> {
new Slide(
title: NO_SIGN_UP,
description: SEND_AND_RECEIVE_FILES_WITH_NO_NEED_TO_SIGN_UP,
subTitleTextFontSize: 14.0,
titleTextFontSize: 23.0,
pathImage: PRIVACY_IMG,
backgroundColor: Colors.black,
btnTitle: NEXT,
Expand All @@ -49,6 +53,8 @@ class IntroScreenState extends State<IntroScreen> {
new Slide(
title: DEVICE_TO_DEVICE,
description: SEND_AND_RECEIVE_FROM_AND_TO_YOUR_DEVICE_WITHOUT_STORING,
subTitleTextFontSize: 14.0,
titleTextFontSize: 23.0,
btnTitle: START_HERE,
maxLineTextDescription: 3,
pathImage: DEVICE_TO_DEVICE_IMG,
Expand Down Expand Up @@ -89,16 +95,13 @@ class IntroScreenState extends State<IntroScreen> {
colorDot: Theme.of(context).scaffoldBackgroundColor,
colorActiveDot: Theme.of(context).colorScheme.secondary,
sizeDot: 13.0,
subTitleFontSize: 18.0.sp,
titleFontSize: 22.0.sp,
hideStatusBar: false,
backgroundColorAllSlides: Colors.grey,
verticalScrollbarBehavior: scrollbarBehavior.SHOW_ALWAYS,
),
builder: (context, widget) {
ScreenUtil.setContext(context);
return MediaQuery(
//Setting font does not change with system font size
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
child: widget!,
);
Expand Down
11 changes: 3 additions & 8 deletions lib/views/mobile/splash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import 'package:dart_wormhole_gui/constants/app_constants.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';

class Splash extends StatefulWidget {
@override
SplashState createState() => new SplashState();
}

class SplashState extends State<Splash> {
class Splash extends StatelessWidget {
SharedPreferences? prefs;
Future isItAppFirstLunch() async {
prefs = await SharedPreferences.getInstance();
Expand All @@ -20,7 +15,7 @@ class SplashState extends State<Splash> {
return prefs?.setBool(SEEN, true);
}

Future checkFirstSeen() async {
Future checkFirstSeen(context) async {
bool isItFirstLunch = await isItAppFirstLunch();
if (isItFirstLunch) {
Navigator.pushNamed(context, SEND_ROUTE);
Expand All @@ -32,7 +27,7 @@ class SplashState extends State<Splash> {

@override
Widget build(BuildContext context) {
checkFirstSeen();
checkFirstSeen(context);
return Scaffold(
body: Center(
key: Key(SPLASH_SCREEN_BODY),
Expand Down
4 changes: 2 additions & 2 deletions lib/views/mobile/widgets/buttons/ButtonWithBackground.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class ButtonWithBackground extends StatelessWidget {
@override
Widget build(BuildContext context) {
Widget getButtonContent() {
return GestureDetector(
onTap: () {
return TextButton(
onPressed: () {
if (disabled == false) this.handleClicked();
},
child: Row(
Expand Down
8 changes: 7 additions & 1 deletion macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ PODS:
- FlutterMacOS
- desktop_drop (0.0.1):
- FlutterMacOS
- device_info_plus_macos (0.0.1):
- FlutterMacOS
- FlutterMacOS (1.0.0)
- path_provider_macos (0.0.1):
- FlutterMacOS
Expand All @@ -14,6 +16,7 @@ PODS:
DEPENDENCIES:
- dart_wormhole_william (from `Flutter/ephemeral/.symlinks/plugins/dart_wormhole_william/macos`)
- desktop_drop (from `Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos`)
- device_info_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus_macos/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)
- shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`)
Expand All @@ -24,6 +27,8 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/dart_wormhole_william/macos
desktop_drop:
:path: Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos
device_info_plus_macos:
:path: Flutter/ephemeral/.symlinks/plugins/device_info_plus_macos/macos
FlutterMacOS:
:path: Flutter/ephemeral
path_provider_macos:
Expand All @@ -36,11 +41,12 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
dart_wormhole_william: 9e7432dc3d48303a2feb57a88fa2795562bdb03e
desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898
device_info_plus_macos: 1ad388a1ef433505c4038e7dd9605aadd1e2e9c7
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
shared_preferences_macos: a64dc611287ed6cbe28fd1297898db1336975727
window_size: 339dafa0b27a95a62a843042038fa6c3c48de195

PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

COCOAPODS: 1.11.2
COCOAPODS: 1.11.3
Loading

0 comments on commit 9fe1c43

Please sign in to comment.