Skip to content

Commit

Permalink
Feature: Swipe Pages and Animation Effect on deletion (#352)
Browse files Browse the repository at this point in the history
* Feature: Replacing settings icon in the timer section to menu icon

* rollback

* Feature: Adding swipeable view
  • Loading branch information
duckcommit authored Jan 17, 2024
1 parent 7273add commit 98c0acd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ import 'package:ultimate_alarm_clock/app/modules/bottomNavigationBar/controllers
import 'package:ultimate_alarm_clock/app/utils/utils.dart';

class BottomNavigationBarView extends GetView<BottomNavigationBarController> {
const BottomNavigationBarView({Key? key}) : super(key: key);
final PageController pageController = PageController();

@override
Widget build(BuildContext context) {
return Scaffold(
body: Obx(
() => IndexedStack(
index: controller.activeTabIndex.value,
children: controller.pages,
),
body: PageView(
controller: pageController,
children: controller.pages,
onPageChanged: (index) {
controller.changeTab(index);
},
),
bottomNavigationBar: Obx(
() => BottomNavigationBar(
useLegacyColorScheme: false,
items: [
items: [
BottomNavigationBarItem(
icon: Icon(Icons.alarm),
label: 'Alarm'.tr,
Expand All @@ -31,10 +32,13 @@ class BottomNavigationBarView extends GetView<BottomNavigationBarController> {
onTap: (index) {
Utils.hapticFeedback();
controller.changeTab(index);
pageController.animateToPage(index,
duration: Duration(milliseconds: 300), curve: Curves.easeInOut);
},
currentIndex: controller.activeTabIndex.value,
),
),
);
}
}

19 changes: 17 additions & 2 deletions lib/app/modules/home/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,8 @@ class HomeView extends GetView<HomeController> {
),
Text(
'Add an alarm to get started!'.tr,
textWidthBasis: TextWidthBasis.longestLine,
textWidthBasis:
TextWidthBasis.longestLine,
style: Theme.of(context)
.textTheme
.displaySmall!
Expand Down Expand Up @@ -850,10 +851,24 @@ class HomeView extends GetView<HomeController> {
Utils.getRepeatDays(alarm.days);
// Main card
return Dismissible(
direction: DismissDirection.startToEnd,
onDismissed: (direction) async {
await controller.swipeToDeleteAlarm(controller.userModel.value,alarm);
await controller.swipeToDeleteAlarm(
controller.userModel.value,
alarm);
},
key: ValueKey(alarms[index]),
background: Container(
color: Colors
.red, // Set the background color to red
padding: EdgeInsets.symmetric(
horizontal: 20),
alignment: Alignment.center,
child: Icon(
Icons.delete,
color: Colors.white,
),
),
child: Obx(
() => GestureDetector(
onTap: () {
Expand Down
2 changes: 1 addition & 1 deletion lib/app/routes/app_pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class AppPages {
),
GetPage(
name: _Paths.BOTTOM_NAVIGATION_BAR,
page: () => const BottomNavigationBarView(),
page: () => BottomNavigationBarView(),
binding: BottomNavigationBarBinding(),
),
GetPage(
Expand Down

0 comments on commit 98c0acd

Please sign in to comment.