Skip to content

Commit

Permalink
Make generic expansion card stateless
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes committed Jul 12, 2023
1 parent dd041a1 commit c41385e
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions uni/lib/view/common_widgets/generic_expansion_card.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import 'package:flutter/material.dart';
import 'package:expansion_tile_card/expansion_tile_card.dart';
import 'package:flutter/material.dart';

/// Card with a expansible child
abstract class GenericExpansionCard extends StatefulWidget {
abstract class GenericExpansionCard extends StatelessWidget {
const GenericExpansionCard({Key? key}) : super(key: key);

@override
State<StatefulWidget> createState() {
return GenericExpansionCardState();
}

TextStyle? getTitleStyle(BuildContext context) => Theme.of(context)
.textTheme
.headlineSmall
?.apply(color: Theme.of(context).primaryColor);

String getTitle();

Widget buildCardContent(BuildContext context);
}

class GenericExpansionCardState extends State<GenericExpansionCard> {
@override
Widget build(BuildContext context) {
return Container(
Expand All @@ -31,12 +25,12 @@ class GenericExpansionCardState extends State<GenericExpansionCard> {
expandedColor: (Theme.of(context).brightness == Brightness.light)
? const Color.fromARGB(0xf, 0, 0, 0)
: const Color.fromARGB(255, 43, 43, 43),
title: Text(widget.getTitle(), style: widget.getTitleStyle(context)),
title: Text(getTitle(), style: getTitleStyle(context)),
elevation: 0,
children: <Widget>[
Container(
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
child: widget.buildCardContent(context),
child: buildCardContent(context),
)
],
));
Expand Down

0 comments on commit c41385e

Please sign in to comment.