Skip to content

Commit

Permalink
Merge pull request #143 from egovernments/audit_fix_6
Browse files Browse the repository at this point in the history
updated timeline molecule and language page card story
  • Loading branch information
rachana-egov authored Nov 11, 2024
2 parents 5297b53 + cfcbb37 commit f3282c8
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 826 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class _TimelineMoleculeState extends LocalizedState<TimelineMolecule> {
List<TimelineStep> stepsToShow = [];
int firstFutureIndex = 0;

if (widget.showAllSteps) {
if (widget.showAllSteps || (showMoreFuture && showMorePast)) {
// Show all steps, including future steps in reverse order
List<TimelineStep> futureSteps = sortedSteps
.where((step) => step.state == TimelineStepState.future)
Expand All @@ -46,7 +46,7 @@ class _TimelineMoleculeState extends LocalizedState<TimelineMolecule> {
stepsToShow.addAll(
sortedSteps.where((step) => step.state == TimelineStepState.present));
stepsToShow.addAll(sortedSteps
.where((step) => step.state == TimelineStepState.completed));
.where((step) => step.state == TimelineStepState.completed).toList().reversed);

firstFutureIndex = sortedSteps
.lastIndexWhere((step) => step.state == TimelineStepState.future);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MatrixListComponent extends StatelessWidget {
final IconData? icon;
final String heading;
final List<MatrixModel>? matrixList; // Matrix list is now optional
final List<ActionItem> actions;
final List<ActionItem>? actions;
final bool filledIcon;
final Widget? centerWidget;
final Widget? additionalWidget;
Expand All @@ -20,7 +20,7 @@ class MatrixListComponent extends StatelessWidget {
this.icon,
required this.heading,
this.matrixList,
required this.actions,
this.actions,
this.centerWidget,
this.additionalWidget,
this.filledIcon = false,
Expand All @@ -46,9 +46,9 @@ class MatrixListComponent extends StatelessWidget {
children: [
if (!showIconOnRight && icon != null) _buildIcon(context),
if (!showIconOnRight && icon != null)
const SizedBox(width: 8),
const SizedBox(width: spacer2),
if (!showIconOnRight && icon != null && filledIcon)
const SizedBox(width: 8),
const SizedBox(width: spacer2),
Flexible(
child: Text(
heading,
Expand All @@ -60,46 +60,46 @@ class MatrixListComponent extends StatelessWidget {
),
),
if (showIconOnRight && icon != null)
const SizedBox(width: 8),
const SizedBox(width: spacer2),
if (showIconOnRight && icon != null) _buildIcon(context),
],
),
),
const SizedBox(height: 16),
const SizedBox(height: spacer4),
const DigitDivider(
dividerType: DividerType.small,
),
const SizedBox(height: 16),
const SizedBox(height: spacer4),
if (matrixList != null && matrixList!.isNotEmpty)
_buildMatrixList(context),
if (matrixList != null && matrixList!.isNotEmpty)
const SizedBox(
height: 16,
height: spacer4,
),
if (matrixList != null && matrixList!.isNotEmpty)
const DigitDivider(dividerType: DividerType.small),
if (matrixList != null && matrixList!.isNotEmpty)
const SizedBox(height: 16),
const SizedBox(height: spacer4),
if (centerWidget != null) ...[
centerWidget!,
const SizedBox(height: 16),
const SizedBox(height: spacer4),
const DigitDivider(dividerType: DividerType.small),
const SizedBox(height: 16),
const SizedBox(height: spacer4),
],
if(actions != null && actions!.isNotEmpty)
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
for (var i = 0; i < actions.length; i++) ...[
ActionDigitButton(action: actions[i]),
if (i < actions.length - 1) const SizedBox(height: 16),
// Add gap between items
for (var i = 0; i < actions!.length; i++) ...[
ActionDigitButton(action: actions![i]),
if (i < actions!.length - 1) const SizedBox(height: spacer4),
],
],
),
if (additionalWidget != null) ...[
const SizedBox(height: 16),
const SizedBox(height: spacer4),
const DigitDivider(dividerType: DividerType.small),
const SizedBox(height: 16),
const SizedBox(height: spacer4),
additionalWidget!,
],
],
Expand All @@ -109,25 +109,28 @@ class MatrixListComponent extends StatelessWidget {
}

Widget _buildIcon(BuildContext context) {
final theme = Theme.of(context);

bool isMobile = AppView.isMobileView(MediaQuery
.of(context)
.size);
bool isTab = AppView.isTabletView(MediaQuery
.of(context)
.size);

return Container(
padding: const EdgeInsets.all(8),
padding: const EdgeInsets.all(spacer2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: filledIcon
? const DigitColors().light.primary1
: const DigitColors().light.paperPrimary,
? theme.colorTheme.primary.primary1
: theme.colorTheme.paper.primary,
),
child: Icon(
icon,
color: filledIcon
? const DigitColors().light.paperPrimary
: const DigitColors().light.primary1,
? theme.colorTheme.paper.primary
: theme.colorTheme.primary.primary1,
size: isMobile
? 28
: isTab
Expand All @@ -147,7 +150,7 @@ class MatrixListComponent extends StatelessWidget {
int index = entry.key;
var matrix = entry.value;

return Flexible( // Use Flexible or Expanded to ensure the text fits the available space
return Flexible(
child: Padding(
padding: EdgeInsets.only(right: index == matrixList!.length - 1 ? 0 : 16.0),
child: Column(
Expand All @@ -158,6 +161,7 @@ class MatrixListComponent extends StatelessWidget {
Text(
matrix.title,
maxLines: 10,
textAlign: alignCenterMatrixList ? TextAlign.center : TextAlign.start,
overflow: TextOverflow.ellipsis,
style: textTheme.headingM.copyWith(
color: theme.colorTheme.text.primary,
Expand All @@ -167,6 +171,7 @@ class MatrixListComponent extends StatelessWidget {
Text(
matrix.description,
maxLines: 10,
textAlign: alignCenterMatrixList ? TextAlign.center : TextAlign.start,
overflow: TextOverflow.ellipsis,
style: textTheme.bodyXS.copyWith(
color: theme.colorTheme.text.secondary,
Expand Down Expand Up @@ -210,7 +215,7 @@ class ActionDigitButton extends StatelessWidget {
Icon(
action.icon,
color: theme.colorTheme.primary.primary1,
size: 20,
size: spacer5,
),
if (action.icon != null)
const SizedBox(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ class DigitLanguageCard extends StatelessWidget {
vertical: spacer4,
horizontal: spacer4,
),
margin: const EdgeInsets.all(spacer2),
children: [
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
appLogo ?? const SizedBox.shrink(),
if(appLogo != null) const SizedBox(height: spacer4,),
DigitRowCard(
spacing: spacer2,
spacing: spacer4,
alignment: WrapAlignment.spaceBetween,
onChanged: onLanguageChange,
rowItems: digitRowCardItems,
Expand Down Expand Up @@ -98,7 +98,6 @@ class _DigitRowCardState extends State<DigitRowCard> {
@override
void initState() {
super.initState();
_calculateMaxLabelWidth();
}

// Function to calculate the width of the largest label based on the text theme of the current screen
Expand Down Expand Up @@ -139,7 +138,8 @@ class _DigitRowCardState extends State<DigitRowCard> {
final theme = Theme.of(context);
final textTheme = theme.digitTextTheme(context);

return GestureDetector(

return InkWell(
onTap: () => _onItemTap(item),
child: Container(
width: max(itemWidth, maxLabelWidth), // Use the calculated width
Expand Down Expand Up @@ -180,6 +180,7 @@ class _DigitRowCardState extends State<DigitRowCard> {
final totalSpacing = (widget.rowItems.length - 1) * widget.spacing;
final availableWidth = screenWidth - totalSpacing;
final itemWidth = availableWidth / widget.rowItems.length;
_calculateMaxLabelWidth();

return Wrap(
spacing: widget.spacing,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:digit_ui_components/digit_components.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import '../atoms/digit_button.dart';
import '../atoms/panel.dart';
import '../helper_widget/button_list.dart';

Expand Down
Loading

0 comments on commit f3282c8

Please sign in to comment.