-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): adaptive TrackTile actions & Setting ListTile
- Loading branch information
Showing
9 changed files
with
285 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:spotube/hooks/useBreakpoints.dart'; | ||
|
||
class AdaptiveListTile extends HookWidget { | ||
final Widget? trailing; | ||
final Widget? title; | ||
final Widget? subtitle; | ||
final Widget? leading; | ||
final void Function()? onTap; | ||
final Breakpoints breakOn; | ||
|
||
const AdaptiveListTile({ | ||
super.key, | ||
this.trailing, | ||
this.onTap, | ||
this.title, | ||
this.subtitle, | ||
this.leading, | ||
this.breakOn = Breakpoints.md, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final breakpoint = useBreakpoints(); | ||
|
||
return ListTile( | ||
title: title, | ||
subtitle: subtitle, | ||
trailing: breakpoint.isLessThan(breakOn) ? null : trailing, | ||
leading: leading, | ||
onTap: breakpoint.isLessThan(breakOn) | ||
? () { | ||
onTap?.call(); | ||
showDialog( | ||
context: context, | ||
builder: (context) { | ||
return AlertDialog( | ||
title: title != null | ||
? Row( | ||
children: [ | ||
if (leading != null) ...[ | ||
leading!, | ||
const SizedBox(width: 5) | ||
], | ||
Flexible(child: title!), | ||
], | ||
) | ||
: null, | ||
content: trailing, | ||
); | ||
}, | ||
); | ||
} | ||
: null, | ||
); | ||
} | ||
} |
Oops, something went wrong.