Onboarding screen

This commit is contained in:
Wicklow committed 2024-09-19 12:21:55 +02:00
1 parent 4482dedd05
commit cb2db24cfb
13 files changed
+349 -112

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

-1
View File
@@ -1 +0,0 @@
<svg width="202" xmlns="http://www.w3.org/2000/svg" height="226" id="screenshot-a0bd4302-77a3-80a8-8004-37bd20aa43c5" viewBox="0 0 202 226" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1"><g id="shape-a0bd4302-77a3-80a8-8004-37bd20aa43c5" width="55.712395mm" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="62.611897mm" rx="0" ry="0" style="fill: rgb(0, 0, 0);"><g id="shape-a0bd4302-77a3-80a8-8004-37bd20aa43c7"><defs style="fill: rgb(0, 0, 0);"/></g><g id="shape-a0bd4302-77a3-80a8-8004-37bd20aa43c8" rx="0" ry="0" style="fill: rgb(0, 0, 0);"><g id="shape-a0bd4302-77a3-80a8-8004-37bd20aa43c9" style="opacity: 1;"><g class="fills" id="fills-a0bd4302-77a3-80a8-8004-37bd20aa43c9"><path d="M123.705,181.377C123.247,184.370,117.981,186.456,116.284,187.018C114.586,187.579,109.608,181.185,109.060,180.052C108.512,178.919,110.333,170.120,111.147,169.045C111.961,167.970,121.256,158.379,129.650,160.322C138.044,162.265,145.289,167.530,147.481,174.601C148.520,177.955,148.690,185.312,143.508,185.642C141.532,185.767,141.394,178.330,136.390,177.049C130.770,175.610,128.025,176.602,123.705,181.377ZZ" style="stroke-opacity: 1; vector-effect: none; stroke: none; fill-rule: evenodd; stroke-dashoffset: 0; stroke-width: 0.2; stroke-linejoin: miter; stroke-dasharray: none; stroke-miterlimit: 4; fill: rgb(255, 179, 112); fill-opacity: 1;"/></g></g><g id="shape-a0bd4302-77a3-80a8-8004-37bd20aa43ca" style="opacity: 1;"><defs><radialGradient xlink:href="#render-5-linearGradient1738" fx="56.455734" cy="167.68628" id="render-5-radialGradient1740-1-7" fy="167.68628" r="20.579618" gradientTransform="matrix(3.625764, 0.000000, 0.000000, 3.609538, 709.049273, -6084.769515) matrix(1.2029851,0,0,0.16716418,30.282992,144.88817)" cx="56.455734" gradientUnits="userSpaceOnUse"/><linearGradient id="render-5-linearGradient1738"><stop offset="0" id="stop1734" style="stop-color: rgb(131, 131, 131); stop-opacity: 1;"/><stop offset="1" id="stop1736" style="stop-color: rgb(191, 191, 191); stop-opacity: 0;"/></linearGradient><radialGradient id="fill-color-gradient-render-5-0" cx="0.5" cy="0.5" r="0.6174891694652888" gradientTransform="matrix(-1.000000, 0.000776, -0.000776, -1.000000, 1.000388, 0.999612)"><stop offset="0" stop-color="#000000" stop-opacity="1"/><stop offset="1" stop-color="#111111" stop-opacity="0"/></radialGradient><pattern patternUnits="userSpaceOnUse" x="0" y="201.16511000137803" width="179.5259008340936" height="24.83488314049964" id="fill-0-render-5"><g><rect width="179.5259008340936" height="24.83488314049964" style="fill: url(&quot;#fill-color-gradient-render-5-0&quot;);"/></g></pattern></defs><g class="fills" id="fills-a0bd4302-77a3-80a8-8004-37bd20aa43ca"><ellipse cx="89.7629504170468" cy="213.58255157162785" rx="89.7629504170468" ry="12.41744157024982" transform="matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)" fill="url(#fill-0-render-5)" style="stroke-opacity: 1; vector-effect: none; stroke: none; isolation: auto; color: rgb(0, 0, 0); fill-rule: nonzero; overflow: visible; marker: none; paint-order: markers stroke; image-rendering: auto; stroke-dashoffset: 0; color-rendering: auto; stroke-width: 0.264583px; stroke-linejoin: miter; stroke-dasharray: none; stroke-miterlimit: 4; display: inline; shape-rendering: auto; text-rendering: auto; visibility: visible; color-interpolation: srgb; clip-rule: nonzero; color-interpolation-filters: linearrgb;"/></g></g><g id="shape-a0bd4302-77a3-80a8-8004-37bd20aa43cb" style="opacity: 1;"><g class="fills" id="fills-a0bd4302-77a3-80a8-8004-37bd20aa43cb"><path d="M146.142,148.300C144.793,150.824,150.010,155.066,150.328,159.041C150.647,163.016,150.078,169.755,144.016,173.277C137.955,176.800,144.202,187.491,146.004,188.253C147.805,189.015,152.935,179.664,155.419,173.920C157.903,168.176,157.362,161.846,155.268,157.505C153.302,153.429,146.142,148.300,146.142,148.300ZZ" style="stroke-opacity: 1; vector-effect: none; stroke: none; fill-rule: evenodd; stroke-dashoffset: 0; stroke-width: 0.2; stroke-linejoin: miter; stroke-dasharray: none; stroke-miterlimit: 4; fill: rgb(255, 179, 112); fill-opacity: 1;"/></g></g><g id="shape-a0bd4302-77a3-80a8-8004-37bd20aa43cc"><g class="fills" id="fills-a0bd4302-77a3-80a8-8004-37bd20aa43cc"><path d="M121.094,168.861C121.886,168.474,122.637,167.833,123.283,167.032C123.618,166.611,123.862,166.019,123.786,165.510C123.764,165.253,123.673,165.024,123.503,164.904C123.056,164.511,122.406,164.516,121.798,164.766C121.062,165.050,120.351,165.603,119.739,166.283C119.310,166.778,119.158,167.531,119.286,168.092C119.408,168.706,119.836,169.191,120.405,169.081C120.639,169.056,120.912,168.968,121.094,168.861ZZ" style="stroke-opacity: 1; stroke: none; fill-rule: evenodd; stroke-width: 0.365; stroke-linejoin: miter; stroke-dasharray: none; stroke-miterlimit: 4; fill: rgb(255, 253, 251); fill-opacity: 0.461187;"/></g></g><g id="shape-a0bd4302-77a3-80a8-8004-37bd20aa43cd" style="opacity: 1;"><g class="fills" id="fills-a0bd4302-77a3-80a8Line truncated

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

@@ -10,6 +10,7 @@ import 'package:peertube_mobile/shared/peertube_instance/config_models.dart';
import 'package:peertube_mobile/shared/peertube_instance/peertube_instance_providers.dart';
import 'package:peertube_mobile/shared/widgets/async_value.dart';
import 'package:peertube_mobile/shared/widgets/avatar_builder.dart';
import 'package:peertube_mobile/shared/widgets/button.dart';
class VideoChannelMiniature extends ConsumerWidget {
final VideoChannelDetails videoChannel;
@@ -137,18 +138,10 @@ class VideoChannelMiniature extends ConsumerWidget {
if (videoChannel.support != null)
Expanded(
flex: 1,
child: Text(
'Support',
style: textTheme.displayLarge!.copyWith(
shadows: [
Shadow(
color: colorScheme.onSurfaceVariant,
offset: const Offset(0, -4),
),
],
color: Colors.transparent,
decoration: TextDecoration.underline,
),
child: UnderlinedTextButton(
onPressed: () {},
text: 'Support',
textStyle: textTheme.displayLarge!,
),
),
],
@@ -204,7 +204,7 @@ class _VideoListViewState extends ConsumerState<VideoListView>
SizedBox(height: 10),
],
)
: CustomElevatedButtonButton(
: CustomElevatedButton(
onPressed: () {
setState(() {
_isFetching = true;
+1 -1
View File
@@ -112,7 +112,7 @@ class _MyAppState extends ConsumerState<MyApp> {
@override
void didChangeDependencies() {
// clearStorage();
clearStorage();
loadLastInstance();
super.didChangeDependencies();
}
+191 -59
View File
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:lucide_icons/lucide_icons.dart';
import 'package:peertube_mobile/features/account/account_providers.dart';
@@ -9,6 +10,196 @@ import 'package:peertube_mobile/routes/instance_selector_screen.dart';
import 'package:peertube_mobile/shared/peertube_instance/peertube_instance_models.dart';
import 'package:peertube_mobile/shared/peertube_instance/peertube_instance_providers.dart';
import 'package:peertube_mobile/shared/widgets/app_bar.dart';
import 'package:peertube_mobile/shared/widgets/button.dart';
class ExploreScreen extends StatelessWidget {
const ExploreScreen({super.key, required this.showModal});
final bool showModal;
@override
Widget build(BuildContext context) {
if (showModal) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_showMyDialog(context);
});
}
return Scaffold(
appBar: AppBar(
title: const Text(
'Explore',
),
actions: const [
AccountAction(),
],
),
body: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Platforms',
style: Theme.of(context).textTheme.headlineLarge,
),
SizedBox(
height: 225,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: instances.length,
itemBuilder: (context, index) {
final item = instances[index];
return ListItem(
item: item,
bannerUrl:
'https://peertube2.cpy.re/lazy-static/banners/d853452c-f020-4c6f-a4ea-9fc582d68ff2.jpg',
description: 'Description for ${item.name}',
views: 1000,
totalVideos: 50,
);
},
),
),
const SizedBox(
height: 15,
),
Text(
'Content',
style: Theme.of(context).textTheme.headlineLarge,
),
const Spacer(),
const Center(child: Text('🚧')),
const Spacer(),
],
),
),
);
}
Future<void> _showMyDialog(BuildContext context) async {
return showDialog<void>(
context: context,
barrierDismissible:
false, // Empêche de fermer la dialog en cliquant à l'extérieur
builder: (BuildContext context) {
// Utilisation d'un Stack pour contrôler la position de la Dialog
var textTheme = Theme.of(context).textTheme;
return Stack(
children: [
Positioned(
top: 20, // Marge de 20px depuis le haut
left: MediaQuery.of(context).size.width *
0.05, // Centré horizontalement (90% de largeur)
child: Material(
child: Container(
width: MediaQuery.of(context).size.width *
0.9, // 90% de la largeur
height: MediaQuery.of(context).size.height *
0.8, // 70% de la hauteur
decoration: BoxDecoration(
color:
Theme.of(context).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(10), // Coins arrondis
boxShadow: const [
BoxShadow(
color: Colors.black26,
blurRadius: 10,
offset: Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
// Ligne avec la croix pour fermer
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(width: 20), // Espace à gauche
Padding(
padding: const EdgeInsets.all(8.0),
child: IconButton(
icon: const Icon(
LucideIcons.x,
size: 32,
),
onPressed: () {
Navigator.of(context).pop(); // Ferme la dialog
},
),
),
],
),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 50.0),
child: Column(
children: [
Text(
'Explore PeerTube',
style: textTheme.titleLarge,
),
const SizedBox(height: 40),
Text(
'Here\'s a selection of popular content from various PeerTube platforms.',
textAlign: TextAlign.center,
style: textTheme.titleSmall,
),
const SizedBox(height: 20),
Text(
'Set your preferences to display content that suits your tastes!',
textAlign: TextAlign.center,
style: textTheme.titleSmall,
),
],
),
),
const Spacer(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Column(
children: [
CustomElevatedButton(
child: const Text('Define my interests'),
onPressed: () {
Navigator.of(context).pop(); // Ferme la dialog
GoRouter.of(context).push(
'/settings/preferences',
); // Redirige vers une nouvelle page
},
),
const SizedBox(
height: 40,
),
UnderlinedTextButton(
text: 'Not now',
textStyle:
Theme.of(context).textTheme.headlineLarge!,
onPressed: () {
Navigator.of(context)
.pop(); // Ferme simplement la dialog
},
),
const SizedBox(
height: 20,
),
],
),
),
const SizedBox(height: 20),
],
),
),
),
),
],
);
},
);
}
}
class ListItem extends ConsumerWidget {
final PeertubeInstanceItem item;
@@ -138,62 +329,3 @@ class ListItem extends ConsumerWidget {
);
}
}
class ExploreScreen extends StatelessWidget {
const ExploreScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
'Explore',
),
actions: const [
AccountAction(),
],
),
body: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Platforms',
style: Theme.of(context).textTheme.headlineLarge,
),
SizedBox(
height: 225,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: instances.length,
itemBuilder: (context, index) {
final item = instances[index];
return ListItem(
item: item,
bannerUrl:
'https://peertube2.cpy.re/lazy-static/banners/d853452c-f020-4c6f-a4ea-9fc582d68ff2.jpg',
description: 'Description for ${item.name}',
views: 1000,
totalVideos: 50,
);
},
),
),
const SizedBox(
height: 15,
),
Text(
'Content',
style: Theme.of(context).textTheme.headlineLarge,
),
const Spacer(),
const Center(child: Text('🚧')),
const Spacer(),
],
),
),
);
}
}
+3 -4
View File
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:lucide_icons/lucide_icons.dart';
@@ -52,10 +51,10 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
if (!isKeyboard)
SvgPicture.asset(
Image.asset(
width: 200,
'assets/sepia/happy.svg',
semanticsLabel: 'Sepia, PeerTube\'s mascot',
'assets/sepia/happy.png',
semanticLabel: 'Sepia, PeerTube\'s mascot',
),
Text(
t(context)!.login,
+96 -16
View File
@@ -1,31 +1,111 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:peertube_mobile/features/onboarding/onboarding_provider.dart';
import 'package:peertube_mobile/shared/widgets/button.dart';
class OnboardingScreen extends ConsumerWidget {
const OnboardingScreen({super.key});
@override
Widget build(context, ref) {
return Scaffold(
appBar: AppBar(title: const Text('Onboarding')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('Bienvenue dans l\'application !'),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
ref.read(onboardingProvider.notifier).state = true;
if (context.mounted) GoRouter.of(context).go('/explore');
},
child: const Text('Commencer'),
),
],
return SafeArea(
child: Scaffold(
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 50,
),
Padding(
padding: const EdgeInsets.all(30.0),
child: Stack(
children: [
Image.asset(
'assets/what-is-peertube.png',
width: MediaQuery.of(context).size.width * 0.8,
),
Column(
children: [
SizedBox(
height: MediaQuery.of(context).size.width * 0.55,
),
Row(
mainAxisAlignment:
MainAxisAlignment.end, // Aligner à droite
children: [
Transform(
alignment: Alignment
.center, // Alignement au centre de l'image
transform: Matrix4.identity()
..scale(
-1.0,
1.0,
) // Inverser l'image horizontalement
..rotateZ(
6,
), // Rotation de 45 degrés
child: Image.asset(
width: MediaQuery.of(context).size.width * 0.4,
'assets/sepia/happy.png',
semanticLabel: 'Sepia, PeerTube\'s mascot',
),
),
],
),
],
),
],
),
),
Text(
'Welcome on PeerTube!',
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(height: 8),
const Text(
'PeerTube is... platforms (instances) that...; blablablablablablablabla',
textAlign: TextAlign.center,
),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 50.0),
child: CustomElevatedButton(
onPressed: () {
ref.read(onboardingProvider.notifier).state = true;
if (context.mounted) {
GoRouter.of(context).go('/explore?showModal=true');
}
},
child: const Text('I know where to go'),
),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset('assets/explore_selected.svg'),
const SizedBox(
width: 10,
),
UnderlinedTextButton(
onPressed: () {
ref.read(onboardingProvider.notifier).state = true;
if (context.mounted) {
GoRouter.of(context).go('/explore?showModal=true');
}
},
text: 'Discover content',
textStyle: Theme.of(context).textTheme.headlineLarge!,
),
],
),
],
),
),
),
);
+8 -13
View File
@@ -26,13 +26,7 @@ const List<String> categories = [
'Food',
];
const List<String> tags = [
'Flutter',
'Dart',
'Mobile',
'Web',
'Backend',
];
const List<String> tags = [];
class PreferencesScreen extends ConsumerStatefulWidget {
const PreferencesScreen({super.key});
@@ -133,11 +127,12 @@ class _PreferencesScreenState extends ConsumerState<PreferencesScreen> {
}).toList(),
),
const SizedBox(height: 32),
Text(
'Tags',
style: textTheme.displayMedium!
.copyWith(color: colorScheme.onSecondaryContainer),
),
if (tags.isNotEmpty)
Text(
'Tags',
style: textTheme.displayMedium!
.copyWith(color: colorScheme.onSecondaryContainer),
),
const SizedBox(height: 16),
Wrap(
spacing: 8.0,
@@ -160,7 +155,7 @@ class _PreferencesScreenState extends ConsumerState<PreferencesScreen> {
if (_hasChanged)
Positioned(
bottom: 16,
child: CustomElevatedButtonButton(
child: CustomElevatedButton(
onPressed: _applyChanges,
child: const Text('Appliquer'),
),
+6 -2
View File
@@ -66,7 +66,7 @@ final goRouterProvider = Provider<GoRouter>(
routes: [
GoRoute(
path: '/',
builder: (context, state) => const HomeScreen(),
builder: (_, __) => const HomeScreen(),
routes: [
GoRoute(
path: 'video-channel/:channelHandle',
@@ -106,7 +106,11 @@ final goRouterProvider = Provider<GoRouter>(
routes: [
GoRoute(
path: '/explore',
builder: (_, __) => const ExploreScreen(),
builder: (context, state) {
final bool showModal =
state.uri.queryParameters['showModal'] != null;
return ExploreScreen(showModal: showModal);
},
),
],
),
+36 -2
View File
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
class CustomElevatedButtonButton extends StatelessWidget {
class CustomElevatedButton extends StatelessWidget {
final VoidCallback onPressed;
final Widget child;
const CustomElevatedButtonButton({
const CustomElevatedButton({
super.key,
required this.onPressed,
required this.child,
@@ -22,3 +22,37 @@ class CustomElevatedButtonButton extends StatelessWidget {
);
}
}
class UnderlinedTextButton extends StatelessWidget {
final VoidCallback onPressed;
final String text;
final TextStyle textStyle;
const UnderlinedTextButton({
super.key,
required this.onPressed,
required this.text,
required this.textStyle,
});
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return GestureDetector(
onTap: onPressed,
child: Text(
text,
style: textStyle.copyWith(
shadows: [
Shadow(
color: colorScheme.onSurfaceVariant,
offset: const Offset(0, -4),
),
],
color: Colors.transparent,
decoration: TextDecoration.underline,
),
),
);
}
}
+2 -1
View File
@@ -77,7 +77,8 @@ flutter:
- assets/library_selected.svg
- assets/explore.svg
- assets/explore_selected.svg
- assets/sepia/happy.svg
- assets/sepia/happy.png
- assets/what-is-peertube.png
fonts:
- family: "Source Sans Pro"
fonts: