Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@ import 'package:paintroid/ui/pages/onboarding_page/components/onboarding_page_bo
import 'package:paintroid/ui/theme/theme.dart';

class BottomNavigationBarContainer extends StatelessWidget {
final List<BottomNavigationBarItem> navBarItems;
final List<VoidCallback> onPressedFunctions;
final List<BottomNavItemData> items;

const BottomNavigationBarContainer({
super.key,
required this.navBarItems,
required this.onPressedFunctions,
required this.items,
});

@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 10),
padding: const EdgeInsets.symmetric(vertical: 20),
color: PaintroidTheme.of(context).surfaceColor,
child: OnboardingPageBottomNavigationBar(
onPressedFunctions: onPressedFunctions,
barItems: navBarItems,
items: items,
),
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,73 @@ import 'package:flutter/material.dart';
import 'package:paintroid/ui/theme/theme.dart';


class BottomNavItemData {
final String label;
final Widget icon;
final VoidCallback onPressed;

const BottomNavItemData({
required this.label,
required this.icon,
required this.onPressed,
});
}

class OnboardingPageBottomNavigationBar extends StatefulWidget {
final List<VoidCallback> onPressedFunctions;
final List<BottomNavigationBarItem> barItems;
final List<BottomNavItemData> items;

const OnboardingPageBottomNavigationBar(
{super.key, required this.onPressedFunctions, required this.barItems});
{super.key, required this.items});

@override
State<OnboardingPageBottomNavigationBar> createState() =>
_OnboardingPageBottomNavigationBarState();
}

class _OnboardingPageBottomNavigationBarState
extends State<OnboardingPageBottomNavigationBar> {
int _currentIndex = 0;

class _OnboardingPageBottomNavigationBarState extends State<OnboardingPageBottomNavigationBar> {
@override
Widget build(BuildContext context) {
return BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _currentIndex,
backgroundColor: PaintroidTheme.of(context).surfaceColor,
selectedItemColor: PaintroidTheme.of(context).onSurfaceColor,
unselectedItemColor: PaintroidTheme.of(context).onSurfaceColor,
selectedFontSize: 12,
unselectedFontSize: 12,
onTap: (value) {
widget.onPressedFunctions[value]();
setState(() => _currentIndex = value);
},
items: widget.barItems,
final theme = PaintroidTheme.of(context);

return Row(
children: List.generate(widget.items.length, (index) {
final item = widget.items[index];

return Expanded(
child: Container(
color: theme.surfaceColor,
child: InkWell(
onTap: () {
item.onPressed();
setState(() =>index);
},
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
IconTheme(
data: IconThemeData(
color: theme.onSurfaceColor
),
child: item.icon,
),
const SizedBox(height: 4),
Text(
item.label,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
color: theme.onSurfaceColor,
),
),
],
),
),
),
)
);
}),
);
}
}
}
144 changes: 72 additions & 72 deletions lib/ui/pages/onboarding_page/onboarding_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,87 +64,87 @@ class _OnboardingPageState extends State<OnboardingPage> {
final localizations = AppLocalizations.of(context);

return Scaffold(
body: Padding(
padding: const EdgeInsets.only(bottom: 40),
child: Column(
children: [
Expanded(
child: PageView(
controller: _controller,
onPageChanged: (index) {
setState(() => _isLastPage = index == 4);
},
children: const [
Screen1(),
Screen2(),
Screen3(),
Screen4(),
Screen5(),
],
),
),
Container(
height: 1,
color: PaintroidTheme.of(context).onSurfaceColor,
backgroundColor: PaintroidTheme.of(context).surfaceColor,
body: Column(
children: [
Expanded(
child: PageView(
controller: _controller,
onPageChanged: (index) {
setState(() => _isLastPage = index == 4);
},
children: const [
Screen1(),
Screen2(),
Screen3(),
Screen4(),
Screen5(),
],
),
],
),
),
Container(
height: 1,
color: PaintroidTheme.of(context).onSurfaceColor,
),
],
),
bottomSheet: Container(
color: PaintroidTheme.of(context).surfaceColor,
height: 40,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 30),
child: TextButton(
onPressed: () => finish(),
child: Text(
_isLastPage ? '' : localizations.skip.toUpperCase(),
style: TextStyle(
color: PaintroidTheme.of(context).onSurfaceColor,
fontSize: 15,
bottomNavigationBar: SafeArea(
child: Container(
color: PaintroidTheme.of(context).surfaceColor,
height: 40,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 30),
child: TextButton(
onPressed: () => finish(),
child: Text(
_isLastPage ? '' : localizations.skip.toUpperCase(),
style: TextStyle(
color: PaintroidTheme.of(context).onSurfaceColor,
fontSize: 15,
),
),
),
),
),
SmoothPageIndicator(
count: 5,
controller: _controller,
effect: SlideEffect(
dotColor: PaintroidTheme.of(context)
.onSurfaceColor
.withValues(alpha: 0.2),
dotHeight: 8,
dotWidth: 8,
activeDotColor: PaintroidTheme.of(context).onSurfaceColor,
SmoothPageIndicator(
count: 5,
controller: _controller,
effect: SlideEffect(
dotColor: PaintroidTheme.of(context)
.onSurfaceColor
.withValues(alpha: 0.2),
dotHeight: 8,
dotWidth: 8,
activeDotColor: PaintroidTheme.of(context).onSurfaceColor,
),
),
),
Padding(
padding: const EdgeInsets.only(right: 30),
child: TextButton(
onPressed: () async {
if (_isLastPage) {
finish();
} else {
_controller.nextPage(
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
);
}
},
child: Text(
_isLastPage ? localizations.letsGo.toUpperCase() : localizations.next.toUpperCase(),
style: TextStyle(
color: PaintroidTheme.of(context).onSurfaceColor,
fontSize: 15,
Padding(
padding: const EdgeInsets.only(right: 30),
child: TextButton(
onPressed: () async {
if (_isLastPage) {
finish();
} else {
_controller.nextPage(
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
);
}
},
child: Text(
_isLastPage ? localizations.letsGo.toUpperCase() : localizations.next.toUpperCase(),
style: TextStyle(
color: PaintroidTheme.of(context).onSurfaceColor,
fontSize: 15,
),
),
),
),
),
],
],
),
),
),
);
Expand Down
55 changes: 24 additions & 31 deletions lib/ui/pages/onboarding_page/screens/screen2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ class _Screen2State extends State<Screen2> {
List<String> titles = [];
List<String> descriptions = [];

List<String> icons = [
'assets/svg/ic_tools.svg',
'assets/svg/ic_hand.svg',
'',
'assets/svg/ic_layers.svg'
];

String titleText = '';
String descText = '';

Expand All @@ -28,18 +35,25 @@ class _Screen2State extends State<Screen2> {
});
}

void tools() => onPressed(0);

void current() => onPressed(1);

void color() => onPressed(2);

void layers() => onPressed(3);

void undo() => onPressed(4);

void redo() => onPressed(5);

List<BottomNavItemData> _getBottomNavItems(int l, int r) {
return List.generate(
r - l + 1,
(i) {
final index = l + i;

return BottomNavItemData(
label: titles[index],
icon: index != 2 ? BottomBarIcon(asset: icons[index]) : Icon(Icons.check_box_outline_blank, size: 24, color: PaintroidTheme.of(context).onSurfaceColor),
onPressed: () => onPressed(index),
);
},
);
}

@override
Widget build(BuildContext context) {
final localizations = AppLocalizations.of(context);
Expand Down Expand Up @@ -115,29 +129,8 @@ class _Screen2State extends State<Screen2> {
),
),
bottomNavigationBar: OnboardingPageBottomNavigationBar(
onPressedFunctions: [tools, current, color, layers],
barItems: [
BottomNavigationBarItem(
label: localizations.bottomNavigationTools,
icon: BottomBarIcon(asset: 'assets/svg/ic_tools.svg'),
),
BottomNavigationBarItem(
label: localizations.bottomNavigationCurrent,
icon: BottomBarIcon(asset: 'assets/svg/ic_hand.svg'),
),
BottomNavigationBarItem(
label: localizations.bottomNavigationColor,
icon: Icon(
Icons.check_box_outline_blank,
size: 24,
color: PaintroidTheme.of(context).onSurfaceColor,
),
),
BottomNavigationBarItem(
label: localizations.bottomNavigationLayers,
icon: BottomBarIcon(asset: 'assets/svg/ic_layers.svg')),
],
),
items: _getBottomNavItems(0, 3),
)
);
}
}
Loading
Loading