Add base interactive layout "rive" whit animation
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AnimatedBar extends StatelessWidget {
|
||||
const AnimatedBar({
|
||||
Key? key,
|
||||
required this.isActive,
|
||||
}) : super(key: key);
|
||||
|
||||
final bool isActive;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedContainer(
|
||||
margin: const EdgeInsets.only(bottom: 2),
|
||||
duration: const Duration(milliseconds: 200),
|
||||
height: 4,
|
||||
width: isActive ? 20 : 0,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF81B4FF),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(12),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
import '../../../model/menu.dart';
|
||||
import 'animated_bar.dart';
|
||||
|
||||
class BtmNavItem extends StatelessWidget {
|
||||
const BtmNavItem(
|
||||
{super.key,
|
||||
required this.navBar,
|
||||
required this.press,
|
||||
required this.riveOnInit,
|
||||
required this.selectedNav});
|
||||
|
||||
final Menu navBar;
|
||||
final VoidCallback press;
|
||||
final ValueChanged<Artboard> riveOnInit;
|
||||
final Menu selectedNav;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: press,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AnimatedBar(isActive: selectedNav == navBar),
|
||||
SizedBox(
|
||||
height: 36,
|
||||
width: 36,
|
||||
child: Opacity(
|
||||
opacity: selectedNav == navBar ? 1 : 0.5,
|
||||
child: RiveAnimation.asset(
|
||||
navBar.rive.src,
|
||||
artboard: navBar.rive.artboard,
|
||||
onInit: riveOnInit,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class InfoCard extends StatelessWidget {
|
||||
const InfoCard({
|
||||
Key? key,
|
||||
required this.name,
|
||||
required this.bio,
|
||||
}) : super(key: key);
|
||||
|
||||
final String name, bio;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: const CircleAvatar(
|
||||
backgroundColor: Colors.white24,
|
||||
child: Icon(
|
||||
CupertinoIcons.person,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
name,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
subtitle: Text(
|
||||
bio,
|
||||
style: const TextStyle(color: Colors.white70),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
class MenuBtn extends StatelessWidget {
|
||||
const MenuBtn({super.key, required this.press, required this.riveOnInit});
|
||||
|
||||
final VoidCallback press;
|
||||
final ValueChanged<Artboard> riveOnInit;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: press,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(left: 12),
|
||||
height: 40,
|
||||
width: 40,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black12,
|
||||
offset: Offset(0, 3),
|
||||
blurRadius: 8,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: RiveAnimation.asset(
|
||||
"assets/RiveAssets/menu_button.riv",
|
||||
onInit: riveOnInit,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../model/menu.dart';
|
||||
import '../../../utils/rive_utils.dart';
|
||||
import 'info_card.dart';
|
||||
import 'side_menu.dart';
|
||||
|
||||
class SideBar extends StatefulWidget {
|
||||
const SideBar({super.key});
|
||||
|
||||
@override
|
||||
State<SideBar> createState() => _SideBarState();
|
||||
}
|
||||
|
||||
class _SideBarState extends State<SideBar> {
|
||||
Menu selectedSideMenu = sidebarMenus.first;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Container(
|
||||
width: 288,
|
||||
height: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF17203A),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(30),
|
||||
),
|
||||
),
|
||||
child: DefaultTextStyle(
|
||||
style: const TextStyle(color: Colors.white),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const InfoCard(
|
||||
name: "Abu Anwar",
|
||||
bio: "YouTuber",
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 24, top: 32, bottom: 16),
|
||||
child: Text(
|
||||
"Browse".toUpperCase(),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.copyWith(color: Colors.white70),
|
||||
),
|
||||
),
|
||||
...sidebarMenus
|
||||
.map((menu) => SideMenu(
|
||||
menu: menu,
|
||||
selectedMenu: selectedSideMenu,
|
||||
press: () {
|
||||
RiveUtils.chnageSMIBoolState(menu.rive.status!);
|
||||
setState(() {
|
||||
selectedSideMenu = menu;
|
||||
});
|
||||
},
|
||||
riveOnInit: (artboard) {
|
||||
menu.rive.status = RiveUtils.getRiveInput(artboard,
|
||||
stateMachineName: menu.rive.stateMachineName);
|
||||
},
|
||||
))
|
||||
.toList(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 24, top: 40, bottom: 16),
|
||||
child: Text(
|
||||
"History".toUpperCase(),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.copyWith(color: Colors.white70),
|
||||
),
|
||||
),
|
||||
...sidebarMenus2
|
||||
.map((menu) => SideMenu(
|
||||
menu: menu,
|
||||
selectedMenu: selectedSideMenu,
|
||||
press: () {
|
||||
RiveUtils.chnageSMIBoolState(menu.rive.status!);
|
||||
setState(() {
|
||||
selectedSideMenu = menu;
|
||||
});
|
||||
},
|
||||
riveOnInit: (artboard) {
|
||||
menu.rive.status = RiveUtils.getRiveInput(artboard,
|
||||
stateMachineName: menu.rive.stateMachineName);
|
||||
},
|
||||
))
|
||||
.toList(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
import '../../../model/menu.dart';
|
||||
|
||||
class SideMenu extends StatelessWidget {
|
||||
const SideMenu(
|
||||
{super.key,
|
||||
required this.menu,
|
||||
required this.press,
|
||||
required this.riveOnInit,
|
||||
required this.selectedMenu});
|
||||
|
||||
final Menu menu;
|
||||
final VoidCallback press;
|
||||
final ValueChanged<Artboard> riveOnInit;
|
||||
final Menu selectedMenu;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 24),
|
||||
child: Divider(color: Colors.white24, height: 1),
|
||||
),
|
||||
Stack(
|
||||
children: [
|
||||
AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.fastOutSlowIn,
|
||||
width: selectedMenu == menu ? 288 : 0,
|
||||
height: 56,
|
||||
left: 0,
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF6792FF),
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: press,
|
||||
leading: SizedBox(
|
||||
height: 36,
|
||||
width: 36,
|
||||
child: RiveAnimation.asset(
|
||||
menu.rive.src,
|
||||
artboard: menu.rive.artboard,
|
||||
onInit: riveOnInit,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
menu.title,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
181
motula_translate_app/lib/screens/entryPoint/entry_point.dart
Normal file
181
motula_translate_app/lib/screens/entryPoint/entry_point.dart
Normal file
@@ -0,0 +1,181 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
import 'package:motula_translate_app/constants.dart';
|
||||
import 'package:motula_translate_app/screens/home/home_screen.dart';
|
||||
import 'package:motula_translate_app/utils/rive_utils.dart';
|
||||
|
||||
import '../../model/menu.dart';
|
||||
import 'components/btm_nav_item.dart';
|
||||
import 'components/menu_btn.dart';
|
||||
import 'components/side_bar.dart';
|
||||
|
||||
class EntryPoint extends StatefulWidget {
|
||||
const EntryPoint({super.key});
|
||||
|
||||
@override
|
||||
State<EntryPoint> createState() => _EntryPointState();
|
||||
}
|
||||
|
||||
class _EntryPointState extends State<EntryPoint>
|
||||
with SingleTickerProviderStateMixin {
|
||||
bool isSideBarOpen = false;
|
||||
|
||||
Menu selectedBottonNav = bottomNavItems.first;
|
||||
Menu selectedSideMenu = sidebarMenus.first;
|
||||
|
||||
late SMIBool isMenuOpenInput;
|
||||
|
||||
void updateSelectedBtmNav(Menu menu) {
|
||||
if (selectedBottonNav != menu) {
|
||||
setState(() {
|
||||
selectedBottonNav = menu;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
late AnimationController _animationController;
|
||||
late Animation<double> scalAnimation;
|
||||
late Animation<double> animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_animationController = AnimationController(
|
||||
vsync: this, duration: const Duration(milliseconds: 200))
|
||||
..addListener(
|
||||
() {
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
scalAnimation = Tween<double>(begin: 1, end: 0.8).animate(CurvedAnimation(
|
||||
parent: _animationController, curve: Curves.fastOutSlowIn));
|
||||
animation = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
|
||||
parent: _animationController, curve: Curves.fastOutSlowIn));
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animationController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
extendBody: true,
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: backgroundColor2,
|
||||
body: Stack(
|
||||
children: [
|
||||
AnimatedPositioned(
|
||||
width: 288,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.fastOutSlowIn,
|
||||
left: isSideBarOpen ? 0 : -288,
|
||||
top: 0,
|
||||
child: const SideBar(),
|
||||
),
|
||||
Transform(
|
||||
alignment: Alignment.center,
|
||||
transform: Matrix4.identity()
|
||||
..setEntry(3, 2, 0.001)
|
||||
..rotateY(
|
||||
1 * animation.value - 30 * (animation.value) * pi / 180),
|
||||
child: Transform.translate(
|
||||
offset: Offset(animation.value * 265, 0),
|
||||
child: Transform.scale(
|
||||
scale: scalAnimation.value,
|
||||
child: const ClipRRect(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(24),
|
||||
),
|
||||
child: HomePage(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.fastOutSlowIn,
|
||||
left: isSideBarOpen ? 220 : 0,
|
||||
top: 16,
|
||||
child: MenuBtn(
|
||||
press: () {
|
||||
isMenuOpenInput.value = !isMenuOpenInput.value;
|
||||
|
||||
if (_animationController.value == 0) {
|
||||
_animationController.forward();
|
||||
} else {
|
||||
_animationController.reverse();
|
||||
}
|
||||
|
||||
setState(
|
||||
() {
|
||||
isSideBarOpen = !isSideBarOpen;
|
||||
},
|
||||
);
|
||||
},
|
||||
riveOnInit: (artboard) {
|
||||
final controller = StateMachineController.fromArtboard(
|
||||
artboard, "State Machine");
|
||||
|
||||
artboard.addController(controller!);
|
||||
|
||||
isMenuOpenInput =
|
||||
controller.findInput<bool>("isOpen") as SMIBool;
|
||||
isMenuOpenInput.value = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: Transform.translate(
|
||||
offset: Offset(0, 100 * animation.value),
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 12, top: 12, right: 12, bottom: 12),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 24),
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor2.withOpacity(0.8),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(24)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: backgroundColor2.withOpacity(0.3),
|
||||
offset: const Offset(0, 20),
|
||||
blurRadius: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
...List.generate(
|
||||
bottomNavItems.length,
|
||||
(index) {
|
||||
Menu navBar = bottomNavItems[index];
|
||||
return BtmNavItem(
|
||||
navBar: navBar,
|
||||
press: () {
|
||||
RiveUtils.chnageSMIBoolState(navBar.rive.status!);
|
||||
updateSelectedBtmNav(navBar);
|
||||
},
|
||||
riveOnInit: (artboard) {
|
||||
navBar.rive.status = RiveUtils.getRiveInput(artboard,
|
||||
stateMachineName: navBar.rive.stateMachineName);
|
||||
},
|
||||
selectedNav: selectedBottonNav,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
class CourseCard extends StatelessWidget {
|
||||
const CourseCard({
|
||||
Key? key,
|
||||
required this.title,
|
||||
this.color = const Color(0xFF7553F6),
|
||||
this.iconSrc = "assets/icons/ios.svg",
|
||||
}) : super(key: key);
|
||||
|
||||
final String title, iconSrc;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||
height: 280,
|
||||
width: 260,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 6, right: 8),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
||||
color: Colors.white, fontWeight: FontWeight.w600),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 12, bottom: 8),
|
||||
child: Text(
|
||||
"Build and animate an iOS app from scratch",
|
||||
style: TextStyle(
|
||||
color: Colors.white38,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
"61 SECTIONS - 11 HOURS",
|
||||
style: TextStyle(
|
||||
color: Colors.white38,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: List.generate(
|
||||
3,
|
||||
(index) => Transform.translate(
|
||||
offset: Offset((-10 * index).toDouble(), 0),
|
||||
child: CircleAvatar(
|
||||
radius: 20,
|
||||
backgroundImage: AssetImage(
|
||||
"assets/avaters/Avatar ${index + 1}.jpg",
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SvgPicture.asset(iconSrc),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
|
||||
class SecondaryCourseCard extends StatelessWidget {
|
||||
const SecondaryCourseCard({
|
||||
Key? key,
|
||||
required this.title,
|
||||
this.iconsSrc = "assets/icons/ios.svg",
|
||||
this.colorl = const Color(0xFF7553F6),
|
||||
}) : super(key: key);
|
||||
|
||||
final String title, iconsSrc;
|
||||
final Color colorl;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
|
||||
decoration: BoxDecoration(
|
||||
color: colorl,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20))),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.headlineSmall!.copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
"Watch video - 15 mins",
|
||||
style: TextStyle(
|
||||
color: Colors.white60,
|
||||
fontSize: 16,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 40,
|
||||
child: VerticalDivider(
|
||||
// thickness: 5,
|
||||
color: Colors.white70,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
SvgPicture.asset(iconsSrc)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
70
motula_translate_app/lib/screens/home/home_screen.dart
Normal file
70
motula_translate_app/lib/screens/home/home_screen.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../model/course.dart';
|
||||
import 'components/course_card.dart';
|
||||
import 'components/secondary_course_card.dart';
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
bottom: false,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 40),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Text(
|
||||
"Courses",
|
||||
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
|
||||
color: Colors.black, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: courses
|
||||
.map(
|
||||
(course) => Padding(
|
||||
padding: const EdgeInsets.only(left: 20),
|
||||
child: CourseCard(
|
||||
title: course.title,
|
||||
iconSrc: course.iconSrc,
|
||||
color: course.color,
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Text(
|
||||
"Recent",
|
||||
style: Theme.of(context).textTheme.headlineSmall!.copyWith(
|
||||
color: Colors.black, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
...recentCourses
|
||||
.map((course) => Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 20, right: 20, bottom: 20),
|
||||
child: SecondaryCourseCard(
|
||||
title: course.title,
|
||||
iconsSrc: course.iconSrc,
|
||||
colorl: course.color,
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
class AnimatedBtn extends StatelessWidget {
|
||||
const AnimatedBtn({
|
||||
Key? key,
|
||||
required RiveAnimationController btnAnimationController,
|
||||
required this.press,
|
||||
}) : _btnAnimationController = btnAnimationController,
|
||||
super(key: key);
|
||||
|
||||
final RiveAnimationController _btnAnimationController;
|
||||
final VoidCallback press;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: press,
|
||||
child: SizedBox(
|
||||
height: 64,
|
||||
width: 236,
|
||||
child: Stack(
|
||||
children: [
|
||||
RiveAnimation.asset(
|
||||
"assets/RiveAssets/button.riv",
|
||||
controllers: [_btnAnimationController],
|
||||
),
|
||||
Positioned.fill(
|
||||
top: 8,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(CupertinoIcons.arrow_right),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
"Start the course",
|
||||
style: Theme.of(context).textTheme.labelLarge,
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import 'sign_in_form.dart';
|
||||
|
||||
void showCustomDialog(BuildContext context, {required ValueChanged onValue}) {
|
||||
showGeneralDialog(
|
||||
context: context,
|
||||
barrierLabel: "Barrier",
|
||||
barrierDismissible: true,
|
||||
barrierColor: Colors.black.withOpacity(0.5),
|
||||
transitionDuration: const Duration(milliseconds: 400),
|
||||
pageBuilder: (_, __, ___) {
|
||||
return Center(
|
||||
child: Container(
|
||||
height: 670,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 24),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.95),
|
||||
borderRadius: BorderRadius.circular(40),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
offset: const Offset(0, 30),
|
||||
blurRadius: 60,
|
||||
),
|
||||
const BoxShadow(
|
||||
color: Colors.black45,
|
||||
offset: Offset(0, 30),
|
||||
blurRadius: 60,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Scaffold(
|
||||
// backgroundColor: Colors.transparent,
|
||||
body: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
const Text(
|
||||
"Sign in",
|
||||
style: TextStyle(
|
||||
fontSize: 34,
|
||||
fontFamily: "Poppins",
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Text(
|
||||
"Access to 240+ hours of content. Learn design and code, by building real apps with Flutter and Swift.",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
const SignInForm(),
|
||||
const Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Divider(),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
"OR",
|
||||
style: TextStyle(
|
||||
color: Colors.black26,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(child: Divider()),
|
||||
],
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 24),
|
||||
child: Text(
|
||||
"Sign up with Email, Apple or Google",
|
||||
style: TextStyle(color: Colors.black54),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
padding: EdgeInsets.zero,
|
||||
icon: SvgPicture.asset(
|
||||
"assets/icons/email_box.svg",
|
||||
height: 64,
|
||||
width: 64,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
padding: EdgeInsets.zero,
|
||||
icon: SvgPicture.asset(
|
||||
"assets/icons/apple_box.svg",
|
||||
height: 64,
|
||||
width: 64,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
padding: EdgeInsets.zero,
|
||||
icon: SvgPicture.asset(
|
||||
"assets/icons/google_box.svg",
|
||||
height: 64,
|
||||
width: 64,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: -48,
|
||||
child: CircleAvatar(
|
||||
radius: 16,
|
||||
backgroundColor: Colors.white,
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
size: 20,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
transitionBuilder: (_, anim, __, child) {
|
||||
Tween<Offset> tween;
|
||||
// if (anim.status == AnimationStatus.reverse) {
|
||||
// tween = Tween(begin: const Offset(0, 1), end: Offset.zero);
|
||||
// } else {
|
||||
// tween = Tween(begin: const Offset(0, -1), end: Offset.zero);
|
||||
// }
|
||||
|
||||
tween = Tween(begin: const Offset(0, -1), end: Offset.zero);
|
||||
|
||||
return SlideTransition(
|
||||
position: tween.animate(
|
||||
CurvedAnimation(parent: anim, curve: Curves.easeInOut),
|
||||
),
|
||||
// child: FadeTransition(
|
||||
// opacity: anim,
|
||||
// child: child,
|
||||
// ),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
).then(onValue);
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
import 'package:motula_translate_app/screens/entryPoint/entry_point.dart';
|
||||
|
||||
class SignInForm extends StatefulWidget {
|
||||
const SignInForm({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SignInForm> createState() => _SignInFormState();
|
||||
}
|
||||
|
||||
class _SignInFormState extends State<SignInForm> {
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
bool isShowLoading = false;
|
||||
bool isShowConfetti = false;
|
||||
late SMITrigger error;
|
||||
late SMITrigger success;
|
||||
late SMITrigger reset;
|
||||
|
||||
late SMITrigger confetti;
|
||||
|
||||
void _onCheckRiveInit(Artboard artboard) {
|
||||
StateMachineController? controller =
|
||||
StateMachineController.fromArtboard(artboard, 'State Machine 1');
|
||||
|
||||
artboard.addController(controller!);
|
||||
error = controller.findInput<bool>('Error') as SMITrigger;
|
||||
success = controller.findInput<bool>('Check') as SMITrigger;
|
||||
reset = controller.findInput<bool>('Reset') as SMITrigger;
|
||||
}
|
||||
|
||||
void _onConfettiRiveInit(Artboard artboard) {
|
||||
StateMachineController? controller =
|
||||
StateMachineController.fromArtboard(artboard, "State Machine 1");
|
||||
artboard.addController(controller!);
|
||||
|
||||
confetti = controller.findInput<bool>("Trigger explosion") as SMITrigger;
|
||||
}
|
||||
|
||||
void singIn(BuildContext context) {
|
||||
// confetti.fire();
|
||||
setState(() {
|
||||
isShowConfetti = true;
|
||||
isShowLoading = true;
|
||||
});
|
||||
Future.delayed(
|
||||
const Duration(seconds: 1),
|
||||
() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
success.fire();
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() {
|
||||
setState(() {
|
||||
isShowLoading = false;
|
||||
});
|
||||
confetti.fire();
|
||||
// Navigate & hide confetti
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
// Navigator.pop(context);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const EntryPoint(),
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
} else {
|
||||
error.fire();
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() {
|
||||
setState(() {
|
||||
isShowLoading = false;
|
||||
});
|
||||
reset.fire();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
"Email",
|
||||
style: TextStyle(
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 16),
|
||||
child: TextFormField(
|
||||
validator: (value) {
|
||||
if (value!.isEmpty) {
|
||||
return "";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
textInputAction: TextInputAction.next,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: SvgPicture.asset("assets/icons/email.svg"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
"Password",
|
||||
style: TextStyle(
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 16),
|
||||
child: TextFormField(
|
||||
obscureText: true,
|
||||
validator: (value) {
|
||||
if (value!.isEmpty) {
|
||||
return "";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: SvgPicture.asset("assets/icons/password.svg"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 24),
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
singIn(context);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFF77D8E),
|
||||
minimumSize: const Size(double.infinity, 56),
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(10),
|
||||
topRight: Radius.circular(25),
|
||||
bottomRight: Radius.circular(25),
|
||||
bottomLeft: Radius.circular(25),
|
||||
),
|
||||
),
|
||||
),
|
||||
icon: const Icon(
|
||||
CupertinoIcons.arrow_right,
|
||||
color: Color(0xFFFE0037),
|
||||
),
|
||||
label: const Text("Sign In"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
isShowLoading
|
||||
? CustomPositioned(
|
||||
child: RiveAnimation.asset(
|
||||
'assets/RiveAssets/check.riv',
|
||||
fit: BoxFit.cover,
|
||||
onInit: _onCheckRiveInit,
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
isShowConfetti
|
||||
? CustomPositioned(
|
||||
scale: 6,
|
||||
child: RiveAnimation.asset(
|
||||
"assets/RiveAssets/confetti.riv",
|
||||
onInit: _onConfettiRiveInit,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CustomPositioned extends StatelessWidget {
|
||||
const CustomPositioned({super.key, this.scale = 1, required this.child});
|
||||
|
||||
final double scale;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Positioned.fill(
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
width: 100,
|
||||
child: Transform.scale(
|
||||
scale: scale,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
const Spacer(flex: 2),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
132
motula_translate_app/lib/screens/onboding/onboding_screen.dart
Normal file
132
motula_translate_app/lib/screens/onboding/onboding_screen.dart
Normal file
@@ -0,0 +1,132 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
import 'components/animated_btn.dart';
|
||||
import 'components/sign_in_dialog.dart';
|
||||
|
||||
class OnbodingScreen extends StatefulWidget {
|
||||
const OnbodingScreen({super.key});
|
||||
|
||||
@override
|
||||
State<OnbodingScreen> createState() => _OnbodingScreenState();
|
||||
}
|
||||
|
||||
class _OnbodingScreenState extends State<OnbodingScreen> {
|
||||
late RiveAnimationController _btnAnimationController;
|
||||
|
||||
bool isShowSignInDialog = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_btnAnimationController = OneShotAnimation(
|
||||
"active",
|
||||
autoplay: false,
|
||||
);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
width: MediaQuery.of(context).size.width * 1.7,
|
||||
left: 100,
|
||||
bottom: 100,
|
||||
child: Image.asset(
|
||||
"assets/Backgrounds/Spline.png",
|
||||
),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
|
||||
child: const SizedBox(),
|
||||
),
|
||||
),
|
||||
const RiveAnimation.asset(
|
||||
"assets/RiveAssets/shapes.riv",
|
||||
),
|
||||
Positioned.fill(
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
|
||||
child: const SizedBox(),
|
||||
),
|
||||
),
|
||||
AnimatedPositioned(
|
||||
top: isShowSignInDialog ? -50 : 0,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
duration: const Duration(milliseconds: 260),
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Spacer(),
|
||||
const SizedBox(
|
||||
width: 260,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Learn design & code",
|
||||
style: TextStyle(
|
||||
fontSize: 60,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontFamily: "Poppins",
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
"Don’t skip design. Learn design and code, by building real apps with Flutter and Swift. Complete courses about the best tools.",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer(flex: 2),
|
||||
AnimatedBtn(
|
||||
btnAnimationController: _btnAnimationController,
|
||||
press: () {
|
||||
_btnAnimationController.isActive = true;
|
||||
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 800),
|
||||
() {
|
||||
setState(() {
|
||||
isShowSignInDialog = true;
|
||||
});
|
||||
showCustomDialog(
|
||||
context,
|
||||
onValue: (_) {},
|
||||
);
|
||||
// showCustomDialog(
|
||||
// context,
|
||||
// onValue: (_) {
|
||||
// setState(() {
|
||||
// isShowSignInDialog = false;
|
||||
// });
|
||||
// },
|
||||
// );
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 24),
|
||||
child: Text(
|
||||
"Purchase includes access to 30+ courses, 240+ premium tutorials, 120+ hours of videos, source files and certificates."),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user