Skip to content

Commit

Permalink
refactor: run dart format
Browse files Browse the repository at this point in the history
  • Loading branch information
Turtlepaw committed Feb 1, 2025
1 parent a8e5d31 commit d0863be
Show file tree
Hide file tree
Showing 40 changed files with 1,182 additions and 961 deletions.
15 changes: 10 additions & 5 deletions lib/components/bottomSheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ class BottomSheetBuilder extends StatelessWidget {
final List<Widget> children;
final ScrollController scrollController;

const BottomSheetBuilder({super.key, required this.children, required this.scrollController}); // Constructor with required
const BottomSheetBuilder(
{super.key,
required this.children,
required this.scrollController}); // Constructor with required

@override
Widget build(BuildContext context) {
return Material(
child: Container(
decoration: BoxDecoration(
color:Theme.of(context).colorScheme.surfaceContainer
),
color: Theme.of(context).colorScheme.surfaceContainer),
//padding: const EdgeInsets.only(top: 20),
child: ListView(
controller: scrollController,
Expand All @@ -24,7 +26,10 @@ class BottomSheetBuilder extends StatelessWidget {
child: Center(
child: DecoratedBox(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.4),
color: Theme.of(context)
.colorScheme
.onSurfaceVariant
.withOpacity(0.4),
borderRadius: const BorderRadius.all(Radius.circular(2.5)),
),
child: const SizedBox(
Expand All @@ -40,4 +45,4 @@ class BottomSheetBuilder extends StatelessWidget {
),
);
}
}
}
24 changes: 14 additions & 10 deletions lib/components/challenge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class _ChallengeState extends State<Challenge> {
}

void subscribe() {
widget.pb.collection("challenges").subscribe(widget.challenge.id, (newValue) {
widget.pb.collection("challenges").subscribe(widget.challenge.id,
(newValue) {
if (mounted) {
print("Got update (${newValue.action})");
Provider.of<ChallengeProvider>(context, listen: false)
Expand All @@ -46,7 +47,9 @@ class _ChallengeState extends State<Challenge> {

@override
void dispose() {
widget.pb.collection(Collection.challenges).unsubscribe(widget.challenge.id);
widget.pb
.collection(Collection.challenges)
.unsubscribe(widget.challenge.id);
super.dispose();
}

Expand Down Expand Up @@ -86,7 +89,8 @@ class _ChallengeState extends State<Challenge> {
builder: (context, constraints) {
double width;
if (constraints.maxWidth < 400) {
width = constraints.maxWidth - 30; // Fill the width on phones with margin
width =
constraints.maxWidth - 30; // Fill the width on phones with margin
} else {
width = 300; // Limit to ~300 on larger devices
}
Expand Down Expand Up @@ -115,8 +119,8 @@ class _ChallengeState extends State<Challenge> {
child: SizedBox(
width: width,
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 15, horizontal: 25),
padding: const EdgeInsets.symmetric(
vertical: 15, horizontal: 25),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
Expand Down Expand Up @@ -153,7 +157,8 @@ class _ChallengeState extends State<Challenge> {
itemLimit: 5,
children: _challenge.expand["users"]!.map((user) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 3),
padding:
const EdgeInsets.symmetric(horizontal: 3),
child: Avatar(user: user),
);
}).toList(),
Expand All @@ -169,7 +174,6 @@ class _ChallengeState extends State<Challenge> {
},
);
}

}

class Avatar extends StatelessWidget {
Expand All @@ -185,12 +189,12 @@ class Avatar extends StatelessWidget {
size: size,
name: getUsernameFromUser(user),
autoTextSize: true,
style: theme.textTheme.titleMedium?.copyWith(
color: theme.colorScheme.onPrimary),
style: theme.textTheme.titleMedium
?.copyWith(color: theme.colorScheme.onPrimary),
decoration: BoxDecoration(
color: theme.colorScheme.primary,
borderRadius: BorderRadius.circular(50),
),
);
}
}
}
14 changes: 6 additions & 8 deletions lib/components/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ class NewTag extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Container(
padding: const EdgeInsets.symmetric(
horizontal: 4, vertical: 1),
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),
margin: const EdgeInsets.only(left: 7),
decoration: BoxDecoration(
color: theme.colorScheme.primary,
borderRadius: BorderRadius.circular(8)),
child: Row(children: [
Icon(Icons.auto_awesome_rounded, color: theme.colorScheme.onPrimary, size: 15),
Icon(Icons.auto_awesome_rounded,
color: theme.colorScheme.onPrimary, size: 15),
const SizedBox(width: 4),
Text("NEW",
style: theme.textTheme.bodyMedium
?.copyWith(
color:
theme.colorScheme.onPrimary,
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onPrimary,
fontWeight: FontWeight.bold)),
const SizedBox(width: 2),
]));
}
}
}
27 changes: 16 additions & 11 deletions lib/components/communityChallenge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ class _CommunityChallengeState extends State<CommunityChallenge> {
}

void openDialog(BuildContext context) {
final joinedChallenges = Provider.of<ChallengeProvider>(context, listen: false).challenges;
final hasJoined = joinedChallenges.firstWhereOrNull((e) => e.id == _challenge.id) != null;
final joinedChallenges =
Provider.of<ChallengeProvider>(context, listen: false).challenges;
final hasJoined =
joinedChallenges.firstWhereOrNull((e) => e.id == _challenge.id) != null;

if(hasJoined){
if (hasJoined) {
context.push("/challenge/${_challenge.id}");
return;
}
Expand All @@ -78,7 +80,8 @@ class _CommunityChallengeState extends State<CommunityChallenge> {
Widget build(BuildContext context) {
final theme = Theme.of(context);
final joinedChallenges = Provider.of<ChallengeProvider>(context).challenges;
final hasJoined = joinedChallenges.firstWhereOrNull((e) => e.id == _challenge.id) != null;
final hasJoined =
joinedChallenges.firstWhereOrNull((e) => e.id == _challenge.id) != null;

return LayoutBuilder(
builder: (context, constraints) {
Expand Down Expand Up @@ -164,13 +167,15 @@ class _CommunityChallengeState extends State<CommunityChallenge> {
onPressed: () {
openDialog(context);
},
child: hasJoined ? const Row(
children: [
Icon(Symbols.check_rounded),
SizedBox(width: 5),
Text("Joined")
],
) : const Text("Join"))
child: hasJoined
? const Row(
children: [
Icon(Symbols.check_rounded),
SizedBox(width: 5),
Text("Joined")
],
)
: const Text("Join"))
],
)
],
Expand Down
Loading

0 comments on commit d0863be

Please sign in to comment.