Created onboarding
This commit is contained in:
16
lib/screens/onboarding/model/onboarding.model.dart
Normal file
16
lib/screens/onboarding/model/onboarding.model.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class OnboardingModel {
|
||||
final PageController pageController;
|
||||
final bool confirmServerRunning;
|
||||
|
||||
OnboardingModel({
|
||||
required this.pageController,
|
||||
required this.confirmServerRunning,
|
||||
});
|
||||
|
||||
OnboardingModel toggleConfirmServerRunning(bool newValue) => OnboardingModel(
|
||||
pageController: pageController,
|
||||
confirmServerRunning: newValue,
|
||||
);
|
||||
}
|
||||
35
lib/screens/onboarding/provider/onboarding.provider.dart
Normal file
35
lib/screens/onboarding/provider/onboarding.provider.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'package:my_linkding/screens/onboarding/model/onboarding.model.dart';
|
||||
|
||||
part 'onboarding.provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
class Onboarding extends _$Onboarding {
|
||||
@override
|
||||
OnboardingModel build() {
|
||||
return OnboardingModel(
|
||||
pageController: PageController(),
|
||||
confirmServerRunning: false,
|
||||
);
|
||||
}
|
||||
|
||||
void nextPage() {
|
||||
state.pageController.nextPage(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.ease,
|
||||
);
|
||||
}
|
||||
|
||||
void previousPage() {
|
||||
state.pageController.previousPage(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.ease,
|
||||
);
|
||||
}
|
||||
|
||||
void confirmServerRunning() {
|
||||
state = state.toggleConfirmServerRunning(!state.confirmServerRunning);
|
||||
}
|
||||
}
|
||||
25
lib/screens/onboarding/provider/onboarding.provider.g.dart
Normal file
25
lib/screens/onboarding/provider/onboarding.provider.g.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'onboarding.provider.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$onboardingHash() => r'5c876d53acbca92ab15630516099700609aa4f89';
|
||||
|
||||
/// See also [Onboarding].
|
||||
@ProviderFor(Onboarding)
|
||||
final onboardingProvider =
|
||||
AutoDisposeNotifierProvider<Onboarding, OnboardingModel>.internal(
|
||||
Onboarding.new,
|
||||
name: r'onboardingProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$onboardingHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$Onboarding = AutoDisposeNotifier<OnboardingModel>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||
29
lib/screens/onboarding/ui/onboarding.dart
Normal file
29
lib/screens/onboarding/ui/onboarding.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:my_linkding/screens/onboarding/provider/onboarding.provider.dart';
|
||||
import 'package:my_linkding/screens/onboarding/ui/server_required.dart';
|
||||
import 'package:my_linkding/screens/onboarding/ui/welcome.dart';
|
||||
import 'package:my_linkding/widgets/system_overlay_style.dart';
|
||||
|
||||
class Onboarding extends ConsumerWidget {
|
||||
const Onboarding({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return OverlayStyle(
|
||||
child: Scaffold(
|
||||
body: SafeArea(
|
||||
child: PageView(
|
||||
controller: ref.watch(onboardingProvider).pageController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: const [
|
||||
OnboardingWelcome(),
|
||||
OnboardingServerRequired(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
132
lib/screens/onboarding/ui/server_required.dart
Normal file
132
lib/screens/onboarding/ui/server_required.dart
Normal file
@@ -0,0 +1,132 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import 'package:my_linkding/screens/onboarding/provider/onboarding.provider.dart';
|
||||
|
||||
import 'package:my_linkding/i18n/strings.g.dart';
|
||||
|
||||
class OnboardingServerRequired extends ConsumerWidget {
|
||||
const OnboardingServerRequired({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.dns_rounded,
|
||||
size: 50,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
t.onboarding.serverRequired,
|
||||
style: const TextStyle(fontSize: 28),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
t.onboarding.serverRequiredDescription,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(height: 24),
|
||||
Card(
|
||||
child: InkWell(
|
||||
onTap: () => {},
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
'assets/resources/github.svg',
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
Flexible(
|
||||
child: Text(
|
||||
t.onboarding.installationInstructions,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.all(8),
|
||||
leading: Checkbox(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
value: ref.watch(onboardingProvider).confirmServerRunning,
|
||||
onChanged: (_) => ref.read(onboardingProvider.notifier).confirmServerRunning(),
|
||||
),
|
||||
title: Text(
|
||||
t.onboarding.serverRunningConfirmation,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () => ref.read(onboardingProvider.notifier).confirmServerRunning(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
FilledButton(
|
||||
onPressed: () => ref.read(onboardingProvider.notifier).previousPage(),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.arrow_back_rounded),
|
||||
const SizedBox(width: 8),
|
||||
Text(t.onboarding.previous),
|
||||
],
|
||||
),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: ref.watch(onboardingProvider).confirmServerRunning == true
|
||||
? () => ref.read(onboardingProvider.notifier).nextPage()
|
||||
: null,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(t.onboarding.next),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(Icons.arrow_forward_rounded),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
79
lib/screens/onboarding/ui/welcome.dart
Normal file
79
lib/screens/onboarding/ui/welcome.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:my_linkding/i18n/strings.g.dart';
|
||||
import 'package:my_linkding/screens/onboarding/provider/onboarding.provider.dart';
|
||||
|
||||
class OnboardingWelcome extends ConsumerWidget {
|
||||
const OnboardingWelcome({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final width = MediaQuery.of(context).size.width;
|
||||
final height = MediaQuery.of(context).size.height;
|
||||
|
||||
final iconSize = width > height ? height : width;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Stack(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
color: Colors.red,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
t.onboarding.title,
|
||||
style: const TextStyle(fontSize: 28),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
t.onboarding.subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const SizedBox(),
|
||||
FilledButton(
|
||||
onPressed: () => ref.read(onboardingProvider.notifier).nextPage(),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(t.onboarding.start),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(Icons.arrow_forward_rounded),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Center(
|
||||
child: Transform.rotate(
|
||||
angle: 0.7,
|
||||
child: Icon(
|
||||
Icons.link_rounded,
|
||||
size: iconSize - 48,
|
||||
color: Theme.of(context).colorScheme.secondary.withOpacity(0.2),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user