Skip to content

Commit

Permalink
enhancement feature & fix deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
myaasiinh committed Sep 18, 2024
1 parent 7b54f19 commit 0ee6b8b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.1.0

**Main feature:**
- Improved textButtonActionSecond & textButtonActionFirst to set manual custom value from parameter.
- Fix change deprecated from material state property

## 1.0.9

**Main feature:**
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To use `expandable_cardview`, add this dependency to your `pubspec.yaml` file:

```yaml
dependencies:
expandable_cardview: ^1.0.9
expandable_cardview: ^1.1.0
```
### Import Library
Expand Down Expand Up @@ -42,6 +42,8 @@ ExpandableCard(
'Order': ['Fried Rice', '1', 'RM 10.00'],
'Shipping': ['Street 1', 'City 1', '12345'],
},
textButtonActionFirst: 'Close',
textButtonActionSecond: 'Details',
onPressedButton2: () {
//do something
},
Expand Down
2 changes: 2 additions & 0 deletions example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class MyHomePage extends StatelessWidget {
itemCount: 10,
itemBuilder: (context, index) {
return ExpandableCard(
textButtonActionFirst: 'Close',
textButtonActionSecond: 'Details',
title: 'Fried Rice',
description: 'Confirmed Order',
button2Value: 'Buy Now',
Expand Down
41 changes: 20 additions & 21 deletions lib/expandable_cardview.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: library_private_types_in_public_api, prefer_const_constructors
// ignore_for_file: library_private_types_in_public_api

library nested_expandable_cardview;

Expand All @@ -23,7 +23,13 @@ class ExpandableCard extends StatefulWidget {
/// The label for button 2.
final String? button2Value;

/// Fungsi callback ketika button2 ditekan.
/// The text for the 'Close' button.
final String textButtonActionFirst;

/// The text for the 'Details' button.
final String textButtonActionSecond;

/// Callback function when button2 is pressed.
final VoidCallback? onPressedButton2;

/// The number of section rows.
Expand Down Expand Up @@ -72,6 +78,8 @@ class ExpandableCard extends StatefulWidget {
this.description,
this.button1Value,
this.button2Value,
required this.textButtonActionFirst, // Default text
required this.textButtonActionSecond, // Default text
required this.sectionRowCount,
required this.sectionRowTitles,
this.totalText,
Expand Down Expand Up @@ -127,9 +135,7 @@ class _ExpandableCardState extends State<ExpandableCard> {
children: List.generate(widget.sectionRowCount, (index) {
return Column(
children: [
const Divider(
height: 0,
), // Divider before each sectionRow
const Divider(height: 0),
SectionRow(
title: widget.sectionRowTitles[index],
isExpanded: _expandedSectionIndex == index,
Expand All @@ -138,20 +144,13 @@ class _ExpandableCardState extends State<ExpandableCard> {
},
),
if (_expandedSectionIndex == index)
const Divider(
height: 0,
), // Divider before DetailSection
const Divider(height: 0),
if (_expandedSectionIndex == index)
DetailSection(
detailData: widget.sectionRowData[
widget.sectionRowTitles[index]] ??
[],
detailData: widget.sectionRowData[widget.sectionRowTitles[index]] ?? [],
),
if (_expandedSectionIndex == index ||
index == widget.sectionRowCount - 1)
const Divider(
height: 0,
), // Divider before button1 and button2
if (_expandedSectionIndex == index || index == widget.sectionRowCount - 1)
const Divider(height: 0),
],
);
}),
Expand All @@ -162,7 +161,7 @@ class _ExpandableCardState extends State<ExpandableCard> {
ExpandCollapseButton(
isExpanded: _isExpanded,
onPressed: _toggleSection,
buttonText: _isExpanded ? 'Close' : 'Details',
buttonText: _isExpanded ? widget.textButtonActionSecond : widget.textButtonActionFirst,
textColor: widget.button1TextColor,
buttonBorderRadius: widget.button1BorderRadius,
),
Expand All @@ -171,13 +170,13 @@ class _ExpandableCardState extends State<ExpandableCard> {
child: ElevatedButton(
onPressed: widget.onPressedButton2,
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
backgroundColor: WidgetStateProperty.all<Color>(
widget.button2Color ?? Colors.blue,
),
elevation: MaterialStateProperty.all<double>(
elevation: WidgetStateProperty.all<double>(
widget.button2Elevation ?? 0,
),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
shape: WidgetStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
widget.button2BorderRadius ?? 0,
Expand All @@ -187,7 +186,7 @@ class _ExpandableCardState extends State<ExpandableCard> {
),
child: Text(
widget.button2Value ?? '',
style: TextStyle(color: Colors.white),
style: const TextStyle(color: Colors.white),
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/component/expand_collapse_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ExpandCollapseButton extends StatelessWidget {
style: TextStyle(color: textColor), // Apply custom text color
),
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
shape: WidgetStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(buttonBorderRadius ??
0), // Apply custom border radius or default to 0
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: expandable_cardview
description: The ExpandableCard widget provides a customizable card with expandable sections, facilitating the display of detailed information in collapsible sections.
version: 1.0.9
version: 1.1.0
repository: https://github.com/myaasiinh/expandable_cardview
issue_tracker: https://github.com/myaasiinh/expandable_cardview/issues
maintainer: myaasiinh (@myaasiinh)
Expand Down
2 changes: 2 additions & 0 deletions test/expandable_cardview_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ void main() {
MaterialApp(
home: Scaffold(
body: ExpandableCard(
textButtonActionFirst: 'Close',
textButtonActionSecond: 'Details',
title: 'Test Title',
description: 'Test Description',
button1Value: 'Button 1',
Expand Down

0 comments on commit 0ee6b8b

Please sign in to comment.