Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

Commit c0979bc

Browse files
authored
11 ods component cards horizontal card (#257)
* library : add ods_horizontal_card * library : add ods_small_card.dart component * library : change ods small card style subtitle * library : add color card theme * demo : add keys l10n * app : add card enum * app : change style text component_count_row.dart * demo : add card_customization.dart * app : add card_horizontal component * app : add card horizontal variant in component.dart * documentation : add docs for card horizontal * app and library : add change log * library : add ods_card_image * app : add ods_card_image
1 parent 64a316c commit c0979bc

20 files changed

+623
-182
lines changed

NOTICE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ods-flutter/app/assets/il_radio_buttons.svg
2121
ods-flutter/app/assets/il_switches.png
2222
ods-flutter/app/assets/il_typography.png
2323
ods-flutter/app/assets/placeholder.png
24+
ods-flutter/library/assets/placeholder.png
2425
ods-flutter/app/assets/il_navigation_bar.png
2526
ods-flutter/app/assets/recipes/ic_coffee.svg
2627
ods-flutter/app/assets/recipes/ic_cooking_pot.svg

app/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- ODS - Component - Slider ([#30](https://github.com/Orange-OpenSource/ods-flutter/issues/30))
3131
- ODS - Component - Progress Indicator ([#26](https://github.com/Orange-OpenSource/ods-flutter/issues/26))
3232
- ODS - Component - Dialogs ([#19](https://github.com/Orange-OpenSource/ods-flutter/issues/19))
33+
- ODS - Component - Cards: Horizontal Card ([#11](https://github.com/Orange-OpenSource/ods-flutter/issues/11))
3334

3435
### Changed
3536

app/lib/l10n/ods_flutter_en.arb

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -95,48 +95,26 @@
9595
"type": "text"
9696
},
9797
"componentElementSubtitle": "Subtitle",
98-
"@componentElementSubtitle": {
99-
"description": "Component customization element - Subtitle",
100-
"type": "text"
101-
},
98+
"componentElementText": "Text",
99+
"componentElementDivider": "Divider",
102100

103101
"@_COMPONENTS_CARDS": {},
104102
"componentCardsTitle": "Cards",
105-
"@componentCardsTitle": {
106-
"description": "Component Cards - Title",
107-
"type": "text"
108-
},
109103
"componentCardsDescription": "Cards are important components that can be used to organise and present a number of different types of related information.",
110-
"@componentCardsDescription": {
111-
"description": "Component Cards - Description",
112-
"type": "text"
113-
},
114104
"componentCardClickable": "Clickable card",
115-
"@componentCardClickable": {
116-
"description": "Component Card - Clickable customization",
117-
"type": "text"
118-
},
105+
119106
"@_CARDS_VARIANT": {},
120107
"cardSmallVariantTitle": "Small card",
121-
"@cardSmallVariantTitle": {
122-
"description": "Component - Small card - Title",
123-
"type": "text"
124-
},
125108
"cardSmallVariantSubtitle": "OdsSmallCard",
126-
"@cardSmallVariantSubtitle": {
127-
"description": "Component - Small card - Technical subtitle",
128-
"type": "text"
129-
},
130109
"cardVerticalImageFirstVariantTitle": "Vertical image first card",
131-
"@cardVerticalImageFirstVariantTitle": {
132-
"description": "Component - Vertical image first card - Title",
133-
"type": "text"
134-
},
135110
"cardVerticalImageFirstVariantSubtitle": "OdsVerticalImageFirstCard",
136-
"@cardVerticalImageFirstVariantSubtitle": {
137-
"description": "Component - Vertical image first card - Technical subtitle",
138-
"type": "text"
139-
},
111+
"componentCardHorizontalTitle": "Horizontal card",
112+
"componentCardHorizontalSubtitle": "OdsHorizontalCard",
113+
"componentCardActionButtonCount": "Action buttons",
114+
"componentCardHorizontalImagePosition": "Image position",
115+
"componentCardHorizontalImagePositionStart": "Start",
116+
"componentCardHorizontalImagePositionEnd": "End",
117+
140118
"@_COMPONENTS_CHECKBOXES": {},
141119
"componentCheckboxesTitle": "Checkboxes",
142120
"@componentCheckboxesTitle": {

app/lib/ui/components/cards/card_customization.dart

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:ods_flutter_demo/ui/components/cards/card_enum.dart';
23

34
class _CardCustomization extends InheritedWidget {
45
_CardCustomization({
@@ -25,12 +26,29 @@ class CardCustomization extends StatefulWidget {
2526
CardCustomizationState createState() => CardCustomizationState();
2627

2728
static CardCustomizationState? of(BuildContext context) {
28-
return (context.dependOnInheritedWidgetOfExactType<_CardCustomization>())?.data;
29+
return (context.dependOnInheritedWidgetOfExactType<_CardCustomization>())
30+
?.data;
2931
}
3032
}
3133

3234
class CardCustomizationState extends State<CardCustomization> {
35+
static get minNavigationItemCount => 0;
36+
37+
static get maxNavigationItemCount => 2;
38+
39+
int _numberOfItems = minNavigationItemCount;
40+
41+
int get numberOfItems => _numberOfItems;
42+
43+
set numberOfItems(int value) {
44+
setState(() {
45+
_numberOfItems = value;
46+
});
47+
}
48+
3349
bool _hasSubtitle = true;
50+
bool _hasText = true;
51+
bool _hasDivider = false;
3452
bool _clickable = true;
3553

3654
bool get hasSubtitle => _hasSubtitle;
@@ -40,13 +58,48 @@ class CardCustomizationState extends State<CardCustomization> {
4058
});
4159
}
4260

61+
bool get hasText => _hasText;
62+
set hasText(bool value) {
63+
setState(() {
64+
_hasText = value;
65+
});
66+
}
67+
68+
bool get hasDivider => _hasDivider;
69+
set hasDivider(bool value) {
70+
setState(() {
71+
_hasDivider = value;
72+
});
73+
}
74+
4375
bool get clickable => _clickable;
4476
set clickable(bool value) {
4577
setState(() {
4678
_clickable = value;
4779
});
4880
}
4981

82+
List<CardEnum> _elements = [
83+
CardEnum.start,
84+
CardEnum.end,
85+
];
86+
CardEnum _selectedElement = CardEnum.start;
87+
88+
List<CardEnum> get elements => _elements;
89+
set elements(List<CardEnum> value) {
90+
setState(() {
91+
_elements = value;
92+
});
93+
}
94+
95+
CardEnum get selectedElement => _selectedElement;
96+
97+
set selectedElement(CardEnum value) {
98+
setState(() {
99+
_selectedElement = value;
100+
});
101+
}
102+
50103
@override
51104
Widget build(BuildContext context) {
52105
return _CardCustomization(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_gen/gen_l10n/ods_flutter_app_localizations.dart';
3+
4+
enum CardEnum { start, end }
5+
6+
extension CustomElementExtension on CardEnum {
7+
String stringValue(BuildContext context) {
8+
switch (this) {
9+
case CardEnum.start:
10+
return AppLocalizations.of(context)!
11+
.componentCardHorizontalImagePositionStart;
12+
case CardEnum.end:
13+
return AppLocalizations.of(context)!
14+
.componentCardHorizontalImagePositionEnd;
15+
default:
16+
return "";
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)