-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add card_swiper and basic configuration
- Loading branch information
Showing
4 changed files
with
119 additions
and
24 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
lib/dashboard/home/tab_bar/credentials/list/widgets/credential_list_widget.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import 'package:altme/app/shared/constants/sizes.dart'; | ||
import 'package:altme/app/shared/enum/credential_category.dart'; | ||
import 'package:altme/dashboard/home/tab_bar/credentials/list/widgets/home_credential_item.dart'; | ||
import 'package:altme/dashboard/home/tab_bar/credentials/models/credential_model/credential_model.dart'; | ||
import 'package:altme/dashboard/home/tab_bar/credentials/widgets/credential_widget/add_credential_button.dart'; | ||
import 'package:card_swiper/card_swiper.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class CredentialListWidget extends StatelessWidget { | ||
const CredentialListWidget({ | ||
super.key, | ||
required this.sortedCredentials, | ||
required this.credentialCategory, | ||
}); | ||
|
||
final List<CredentialModel> sortedCredentials; | ||
final CredentialCategory credentialCategory; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return CredentialListStack( | ||
sortedCredentials: sortedCredentials, | ||
credentialCategory: credentialCategory, | ||
); | ||
} | ||
} | ||
|
||
class CredentialListGrid extends StatelessWidget { | ||
const CredentialListGrid({ | ||
super.key, | ||
required this.sortedCredentials, | ||
required this.credentialCategory, | ||
}); | ||
|
||
final List<CredentialModel> sortedCredentials; | ||
final CredentialCategory credentialCategory; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GridView.builder( | ||
physics: const NeverScrollableScrollPhysics(), | ||
shrinkWrap: true, | ||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( | ||
crossAxisCount: 2, | ||
crossAxisSpacing: 14, | ||
mainAxisSpacing: 14, | ||
childAspectRatio: Sizes.credentialAspectRatio, | ||
), | ||
itemCount: sortedCredentials.length + 1, | ||
itemBuilder: (_, index) { | ||
if (index == sortedCredentials.length) { | ||
if (credentialCategory == CredentialCategory.pendingCards) { | ||
return Container(); | ||
} | ||
return AddCredentialButton( | ||
credentialCategory: credentialCategory, | ||
); | ||
} else { | ||
return HomeCredentialItem( | ||
credentialModel: sortedCredentials[index], | ||
); | ||
} | ||
}, | ||
); | ||
} | ||
} | ||
|
||
class CredentialListStack extends StatelessWidget { | ||
const CredentialListStack({ | ||
super.key, | ||
required this.sortedCredentials, | ||
required this.credentialCategory, | ||
}); | ||
|
||
final List<CredentialModel> sortedCredentials; | ||
final CredentialCategory credentialCategory; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
const double cardHeight = 150; | ||
return SizedBox( | ||
height: 200, | ||
child: Swiper( | ||
scrollDirection: Axis.horizontal, | ||
loop: false, | ||
containerHeight: 200, | ||
containerWidth: 150, | ||
itemHeight: cardHeight, | ||
itemWidth: cardHeight * 1.586, | ||
layout: SwiperLayout.CUSTOM, | ||
customLayoutOption: CustomLayoutOption(startIndex: -1, stateCount: 3) | ||
..addRotate([-60.0 / 180, 0.0, 60.0 / 180]) | ||
..addTranslate( | ||
[Offset(-210.0, -20.0), Offset(0.0, 0.0), Offset(210.0, -20.0)]), | ||
itemBuilder: (BuildContext context, int index) { | ||
return HomeCredentialItem( | ||
credentialModel: sortedCredentials[index], | ||
); | ||
}, | ||
itemCount: sortedCredentials.length, | ||
pagination: SwiperPagination(), | ||
control: SwiperControl(), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters