Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
U
UI UX flutter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyen Hoang Giang
UI UX flutter
Commits
1900f62d
Commit
1900f62d
authored
May 17, 2023
by
Nguyen Hoang Giang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Bug and RiveNav
parent
9c53052f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
213 additions
and
11 deletions
+213
-11
instagram/lib/models/menu.dart
instagram/lib/models/menu.dart
+45
-0
instagram/lib/models/rive_assets.dart
instagram/lib/models/rive_assets.dart
+16
-0
instagram/lib/screens/main_screen.dart
instagram/lib/screens/main_screen.dart
+74
-4
instagram/lib/screens/story_screen.dart
instagram/lib/screens/story_screen.dart
+7
-7
instagram/lib/utils/rive_utils.dart
instagram/lib/utils/rive_utils.dart
+19
-0
instagram/lib/widgets/btn_bottom_navigator.dart
instagram/lib/widgets/btn_bottom_navigator.dart
+50
-0
instagram/lib/widgets/cube_widget.dart
instagram/lib/widgets/cube_widget.dart
+2
-0
No files found.
instagram/lib/models/menu.dart
0 → 100644
View file @
1900f62d
import
'package:instagram_clone/models/rive_assets.dart'
;
class
Menu
{
String
title
;
RiveModel
rive
;
Menu
({
required
this
.
rive
,
required
this
.
title
,
});
}
List
<
Menu
>
menu_list
=
[
Menu
(
rive:
RiveModel
(
src:
"assets/RiveAssets/icons.riv"
,
artboard:
"HOME"
,
stateMachineName:
"HOME_interactivity"
),
title:
"Home"
),
Menu
(
rive:
RiveModel
(
src:
"assets/RiveAssets/icons.riv"
,
artboard:
"SEARCH"
,
stateMachineName:
"SEARCH_Interactivity"
),
title:
"SEARCH"
),
Menu
(
title:
"Timer"
,
rive:
RiveModel
(
src:
"assets/RiveAssets/icons.riv"
,
artboard:
"TIMER"
,
stateMachineName:
"TIMER_Interactivity"
),
),
Menu
(
title:
"Notification"
,
rive:
RiveModel
(
src:
"assets/RiveAssets/icons.riv"
,
artboard:
"BELL"
,
stateMachineName:
"BELL_Interactivity"
),
),
];
\ No newline at end of file
instagram/lib/models/rive_assets.dart
0 → 100644
View file @
1900f62d
import
'package:rive/rive.dart'
;
class
RiveModel
{
String
src
,
artboard
,
stateMachineName
;
SMIBool
?
status
;
RiveModel
({
required
this
.
src
,
required
this
.
artboard
,
required
this
.
stateMachineName
,
this
.
status
});
void
setStatus
(
SMIBool
newStatus
){
this
.
status
=
status
;
}
}
\ No newline at end of file
instagram/lib/screens/main_screen.dart
View file @
1900f62d
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:
flutter/src/widgets/framework
.dart'
;
import
'package:
instagram_clone/models/menu
.dart'
;
import
'package:flutter/src/widgets/placeholder.dart'
;
import
'package:instagram_clone/screens/post_screen.dart'
;
import
'package:instagram_clone/screens/post_screen.dart'
;
import
'package:instagram_clone/screens/profile_screen.dart'
;
import
'package:instagram_clone/screens/profile_screen.dart'
;
import
'package:instagram_clone/screens/search_screen.dart'
;
import
'package:instagram_clone/screens/search_screen.dart'
;
import
'package:instagram_clone/screens/video_screen.dart'
;
import
'package:instagram_clone/screens/video_screen.dart'
;
import
'package:instagram_clone/utils/rive_utils.dart'
;
import
'package:instagram_clone/utils/text_utils.dart'
;
import
'package:instagram_clone/utils/text_utils.dart'
;
import
'package:instagram_clone/widgets/btn_bottom_navigator.dart'
;
import
'home_screen.dart'
;
import
'home_screen.dart'
;
...
@@ -18,6 +20,7 @@ class MainScreen extends StatefulWidget {
...
@@ -18,6 +20,7 @@ class MainScreen extends StatefulWidget {
}
}
class
_MainScreenState
extends
State
<
MainScreen
>
{
class
_MainScreenState
extends
State
<
MainScreen
>
{
Menu
selectedNavItem
=
menu_list
.
first
;
int
index
=
0
;
int
index
=
0
;
final
TextUtils
_textUtils
=
TextUtils
();
final
TextUtils
_textUtils
=
TextUtils
();
final
PageController
pageController
=
PageController
(
final
PageController
pageController
=
PageController
(
...
@@ -29,10 +32,77 @@ class _MainScreenState extends State<MainScreen> {
...
@@ -29,10 +32,77 @@ class _MainScreenState extends State<MainScreen> {
return
Scaffold
(
return
Scaffold
(
backgroundColor:
Colors
.
white
,
backgroundColor:
Colors
.
white
,
body:
getScreen
(),
body:
getScreen
(),
bottomNavigationBar:
bottomBarWidget
(),
bottomNavigationBar:
bottomBarRiveWidget
(),
);
}
Widget
bottomBarRiveWidget
(){
return
SafeArea
(
child:
Container
(
padding:
const
EdgeInsets
.
all
(
12
),
margin:
const
EdgeInsets
.
all
(
24
),
decoration:
BoxDecoration
(
color:
Colors
.
black
.
withOpacity
(
0.8
),
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
24
)),
boxShadow:
[
BoxShadow
(
color:
Colors
.
black
.
withOpacity
(
0.3
),
offset:
const
Offset
(
0
,
20
),
blurRadius:
20
,
),
]
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
...
List
.
generate
(
menu_list
.
length
,
(
index
)
=>
BtnNavButton
(
menu:
menu_list
[
index
],
onTap:
()
{
RiveUtils
.
changeSMIBoolState
(
menu_list
[
index
].
rive
.
status
!);
updateNavBtn
(
index
,
menu_list
[
index
]);
},
riveOnInit:
(
artboard
)
{
menu_list
[
index
].
rive
.
status
=
RiveUtils
.
getRiveInput
(
artboard
,
stateMachineName:
menu_list
[
index
].
rive
.
stateMachineName
,
);
},
activeMenu:
selectedNavItem
,
),
),
InkWell
(
onTap:
()
{
index
=
4
;
setState
(()
{
});
},
child:
CircleAvatar
(
backgroundColor:
index
==
4
?
Colors
.
black
:
Colors
.
white
,
radius:
17
,
child:
const
CircleAvatar
(
radius:
15
,
backgroundImage:
AssetImage
(
"assets/avaters/Avatar 1.jpg"
),
),
),
),
],
),
),
);
);
}
}
void
updateNavBtn
(
int
newIndex
,
Menu
newNavBtn
){
setState
(()
{
index
=
newIndex
;
selectedNavItem
=
newNavBtn
;
});
}
Widget
bottomBarWidget
()
{
Widget
bottomBarWidget
()
{
return
Container
(
return
Container
(
padding:
const
EdgeInsets
.
all
(
15
),
padding:
const
EdgeInsets
.
all
(
15
),
...
...
instagram/lib/screens/story_screen.dart
View file @
1900f62d
...
@@ -40,17 +40,17 @@ class _StoryScreenState extends State<StoryScreen> with TickerProviderStateMixin
...
@@ -40,17 +40,17 @@ class _StoryScreenState extends State<StoryScreen> with TickerProviderStateMixin
@override
@override
void
dispose
()
{
void
dispose
()
{
// TODO: implement dispose
// TODO: implement dispose
_pageController
.
dispose
();
_cancelTimer
();
_cancelTimer
();
// Future.delayed(const Duration(milliseconds: 500)).then((value) {_pageController.dispose();});
super
.
dispose
();
super
.
dispose
();
}
}
@override
void
_cancelTimer
()
{
void
_cancelTimer
()
async
{
_timer
?.
cancel
();
_timer
?.
cancel
();
}
}
...
@@ -80,11 +80,11 @@ class _StoryScreenState extends State<StoryScreen> with TickerProviderStateMixin
...
@@ -80,11 +80,11 @@ class _StoryScreenState extends State<StoryScreen> with TickerProviderStateMixin
}
else
{
}
else
{
if
(
_current_page
<
list_image
.
length
-
1
){
if
(
_current_page
<
list_image
.
length
-
1
){
_current_page
++;
_current_page
++;
print
(
"Still Run"
);
_pageController
.
animateToPage
(
_pageController
.
animateToPage
(
_current_page
,
_current_page
,
duration:
const
Duration
(
milliseconds:
300
),
duration:
const
Duration
(
milliseconds:
300
),
curve:
Curves
.
easeOut
);
curve:
Curves
.
easeOut
,
);
_current_timer
=
0.0
;
_current_timer
=
0.0
;
_duration
=
10000
;
_duration
=
10000
;
...
@@ -272,7 +272,7 @@ class _StoryScreenState extends State<StoryScreen> with TickerProviderStateMixin
...
@@ -272,7 +272,7 @@ class _StoryScreenState extends State<StoryScreen> with TickerProviderStateMixin
void
returnHome
()
{
void
returnHome
()
{
_current_page
=
0
;
_current_page
=
0
;
_pageController
=
PageController
(
initialPage:
_current_page
);
//
_pageController = PageController(initialPage: _current_page);
_duration
=
10000
;
_duration
=
10000
;
_current_timer
=
0.0
;
_current_timer
=
0.0
;
_previous_page
=
_current_page
;
_previous_page
=
_current_page
;
...
...
instagram/lib/utils/rive_utils.dart
0 → 100644
View file @
1900f62d
import
'package:rive/rive.dart'
;
class
RiveUtils
{
static
SMIBool
getRiveInput
(
Artboard
artboard
,
{
required
String
stateMachineName
}){
StateMachineController
?
controller
=
StateMachineController
.
fromArtboard
(
artboard
,
stateMachineName
);
artboard
.
addController
(
controller
!);
return
controller
.
findInput
<
bool
>(
"active"
)
as
SMIBool
;
}
static
void
changeSMIBoolState
(
SMIBool
input
)
{
input
.
change
(
true
);
Future
.
delayed
(
const
Duration
(
seconds:
1
),
()
{
input
.
change
(
false
);
}
);
}
}
\ No newline at end of file
instagram/lib/widgets/btn_bottom_navigator.dart
0 → 100644
View file @
1900f62d
import
'package:flutter/material.dart'
;
import
'package:flutter/src/widgets/framework.dart'
;
import
'package:flutter/src/widgets/placeholder.dart'
;
import
'package:instagram_clone/models/menu.dart'
;
import
'package:rive/rive.dart'
;
class
BtnNavButton
extends
StatelessWidget
{
final
Menu
menu
;
final
VoidCallback
onTap
;
final
ValueChanged
<
Artboard
>
riveOnInit
;
final
Menu
activeMenu
;
const
BtnNavButton
({
super
.
key
,
required
this
.
menu
,
required
this
.
onTap
,
required
this
.
riveOnInit
,
required
this
.
activeMenu
});
@override
Widget
build
(
BuildContext
context
)
{
return
GestureDetector
(
onTap:
onTap
,
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
[
AnimatedContainer
(
margin:
const
EdgeInsets
.
only
(
bottom:
2
),
duration:
const
Duration
(
milliseconds:
400
),
height:
4
,
width:
activeMenu
==
menu
?
20
:
0
,
decoration:
const
BoxDecoration
(
color:
Color
(
0xFF81B4FF
),
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
12
)),
),
),
SizedBox
(
width:
36
,
height:
36
,
child:
Opacity
(
opacity:
activeMenu
==
menu
?
1
:
0.5
,
child:
RiveAnimation
.
asset
(
menu
.
rive
.
src
,
artboard:
menu
.
rive
.
artboard
,
onInit:
riveOnInit
,
),
),
),
],
),
);
}
}
\ No newline at end of file
instagram/lib/widgets/cube_widget.dart
View file @
1900f62d
...
@@ -26,6 +26,8 @@ class CubeWidget extends StatefulWidget {
...
@@ -26,6 +26,8 @@ class CubeWidget extends StatefulWidget {
}
}
class
_CubeWidgetState
extends
State
<
CubeWidget
>
{
class
_CubeWidgetState
extends
State
<
CubeWidget
>
{
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
final
isLeaving
=
(
widget
.
index
-
widget
.
pageNotifier
)
<=
0
;
final
isLeaving
=
(
widget
.
index
-
widget
.
pageNotifier
)
<=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment