Skip to content

Commit

Permalink
Merge pull request #136 from humhub/135-remove-the-last-help-page-for…
Browse files Browse the repository at this point in the history
…-the-purpose-of-the-app-store-review

Remove last help page only for iOS platforms.
  • Loading branch information
luke- authored Nov 5, 2023
2 parents 3efee09 + 398282d commit 4a84999
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 18 deletions.
22 changes: 14 additions & 8 deletions lib/components/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ class BottomNavigationState extends State<BottomNavigation> with TickerProviderS
padding: _getPadding(selectedIndex),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildPageIndicator(0),
const SizedBox(width: 8),
_buildPageIndicator(1),
const SizedBox(width: 8),
_buildPageIndicator(2),
],
children: List.generate(
widget.pageCount,
(index) {
return index < widget.pageCount - 1
? Row(
children: [
_buildPageIndicator(index),
const SizedBox(width: 8),
],
)
: _buildPageIndicator(index);
},
),
),
),
),
Expand All @@ -80,7 +86,7 @@ class BottomNavigationState extends State<BottomNavigation> with TickerProviderS
child: TextButton(
onPressed: () => navigateForth(),
child: Text(
selectedIndex != 2 ? "Next" : "Connect now",
selectedIndex != widget.pageCount - 1 ? "Next" : "Connect now",
style: const TextStyle(color: Colors.grey),
),
),
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/help/help.dart → lib/pages/help/help_android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import 'package:humhub/pages/help/components/third_page.dart';
import 'package:swipe_to/swipe_to.dart';
import 'components/second_page.dart';

class Help extends StatefulWidget {
class HelpAndroid extends StatefulWidget {
static const String path = '/help';
const Help({Key? key}) : super(key: key);
const HelpAndroid({Key? key}) : super(key: key);

@override
HelpState createState() => HelpState();
HelpAndroidState createState() => HelpAndroidState();
}

class HelpState extends State<Help> {
class HelpAndroidState extends State<HelpAndroid> {
final ValueNotifier<bool> fadeInFirst = ValueNotifier<bool>(false);
final ValueNotifier<bool> fadeInSecond = ValueNotifier<bool>(false);
final ValueNotifier<bool> fadeInThird = ValueNotifier<bool>(false);
Expand Down
98 changes: 98 additions & 0 deletions lib/pages/help/help_ios.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:humhub/components/bottom_navigation_bar.dart';
import 'package:humhub/components/ease_out_container.dart';
import 'package:humhub/components/help_safe_area.dart';
import 'package:humhub/components/page_animation_container.dart';
import 'package:humhub/pages/help/components/first_page.dart';
import 'package:swipe_to/swipe_to.dart';
import 'components/second_page.dart';

class HelpIos extends StatefulWidget {
static const String path = '/help';
const HelpIos({Key? key}) : super(key: key);

@override
HelpIosState createState() => HelpIosState();
}

class HelpIosState extends State<HelpIos> {
final ValueNotifier<bool> fadeInFirst = ValueNotifier<bool>(false);
final ValueNotifier<bool> fadeInSecond = ValueNotifier<bool>(false);
final ValueNotifier<bool> fadeInThird = ValueNotifier<bool>(false);
final ValueNotifier<int> currentPage = ValueNotifier<int>(0);
GlobalKey<PageAnimationContainerState> statePagesKey = GlobalKey<PageAnimationContainerState>();
GlobalKey<BottomNavigationState> bottomNavigationStateKey = GlobalKey<BottomNavigationState>();

@override
Widget build(BuildContext context) {
return SwipeTo(
offsetDx: 0,
animationDuration: const Duration(milliseconds: 100),
onRightSwipe: () => bottomNavigationStateKey.currentState?.navigateBack(),
onLeftSwipe: () => bottomNavigationStateKey.currentState?.navigateForth(),
child: Scaffold(
backgroundColor: Colors.white,
extendBody: true,
bottomNavigationBar: Container(
padding: Platform.isIOS ? const EdgeInsets.only(bottom: 20) : const EdgeInsets.only(bottom: 5),
margin: const EdgeInsets.symmetric(horizontal: 10),
child: BottomNavigation(
key: bottomNavigationStateKey,
pageCount: 2,
onPageChange: (index) {
currentPage.value = index;
statePagesKey.currentState?.navigateTo(index);
},
),
),
body: HelpSafeArea(
child: Column(
children: [
Center(
child: Container(
padding: const EdgeInsets.only(top: 60, bottom: 40),
width: MediaQuery.of(context).size.width * 0.6,
child: EaseOutContainer(
child: Image.asset('assets/images/logo.png'),
),
),
),
PageAnimationContainer(
key: statePagesKey,
fadeDuration: const Duration(milliseconds: 500),
fadeCurve: Curves.easeInOut,
navigationCallback: (currentIndex, nextIndex) {
if (currentIndex == 0) {
fadeInFirst.value = true;
} else {
fadeInFirst.value = false;
}
if (currentIndex == 1) {
fadeInSecond.value = true;
} else {
fadeInSecond.value = false;
}
},
children: [
ValueListenableBuilder<bool>(
valueListenable: fadeInFirst,
builder: (BuildContext context, value, Widget? child) {
return FirstPage(fadeIn: fadeInFirst.value);
},
),
ValueListenableBuilder<bool>(
valueListenable: fadeInSecond,
builder: (BuildContext context, value, Widget? child) {
return SecondPage(fadeIn: fadeInSecond.value);
},
),
],
),
],
),
),
),
);
}
}
12 changes: 8 additions & 4 deletions lib/pages/opener.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/pages/web_view.dart';
Expand All @@ -6,7 +8,8 @@ import 'package:humhub/util/form_helper.dart';
import 'package:humhub/util/opener_controller.dart';
import 'package:humhub/util/providers.dart';
import 'package:rive/rive.dart';
import 'help/help.dart';
import 'help/help_android.dart';
import 'help/help_ios.dart';

class Opener extends ConsumerStatefulWidget {
const Opener({Key? key}) : super(key: key);
Expand Down Expand Up @@ -39,7 +42,7 @@ class OpenerState extends ConsumerState<Opener> with SingleTickerProviderStateMi
_controllerReverse = _animationReverse;

WidgetsBinding.instance.addPostFrameCallback((_) {
Future.delayed(const Duration(milliseconds: 700), (){
Future.delayed(const Duration(milliseconds: 700), () {
setState(() {
_textFieldAddInfoVisibility = true;
});
Expand Down Expand Up @@ -166,7 +169,8 @@ class OpenerState extends ConsumerState<Opener> with SingleTickerProviderStateMi
context,
PageRouteBuilder(
transitionDuration: const Duration(milliseconds: 500),
pageBuilder: (context, animation, secondaryAnimation) => const Help(),
pageBuilder: (context, animation, secondaryAnimation) =>
Platform.isAndroid ? const HelpAndroid() : const HelpIos(),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
return FadeTransition(
opacity: animation,
Expand All @@ -179,7 +183,7 @@ class OpenerState extends ConsumerState<Opener> with SingleTickerProviderStateMi
_controller.isActive = true;
_animation.reset();
_visible = true;
Future.delayed(const Duration(milliseconds: 700), (){
Future.delayed(const Duration(milliseconds: 700), () {
setState(() {
_textFieldAddInfoVisibility = true;
});
Expand Down
6 changes: 4 additions & 2 deletions lib/util/router.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'dart:io';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/models/hum_hub.dart';
import 'package:humhub/models/manifest.dart';
import 'package:humhub/pages/help/help.dart';
import 'package:humhub/pages/help/help_android.dart';
import 'package:humhub/pages/help/help_ios.dart';
import 'package:humhub/pages/opener.dart';
import 'package:humhub/pages/web_view.dart';
import 'package:humhub/util/providers.dart';
Expand Down Expand Up @@ -33,7 +35,7 @@ class MyRouter {
static var routes = {
Opener.path: (context) => const Opener(),
WebViewApp.path: (context) => const WebViewApp(),
Help.path: (context) => const Help(),
'/help': (context) => Platform.isAndroid ? const HelpAndroid() : const HelpIos(),
};

static Future<String> getInitialRoute(WidgetRef ref) async {
Expand Down

0 comments on commit 4a84999

Please sign in to comment.