-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(neon): Support custom backgrounds
Signed-off-by: jld3103 <[email protected]>
- Loading branch information
1 parent
8f112ea
commit 6700edc
Showing
9 changed files
with
147 additions
and
41 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
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
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,56 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:neon/src/utils/hex_color.dart'; | ||
import 'package:neon/src/widgets/image.dart'; | ||
import 'package:nextcloud/core.dart' as core; | ||
|
||
@internal | ||
class NeonCustomBackground extends StatelessWidget { | ||
const NeonCustomBackground({ | ||
required this.theme, | ||
required this.child, | ||
super.key, | ||
}); | ||
|
||
final core.ThemingPublicCapabilities_Theming? theme; | ||
final Widget? child; | ||
|
||
double _opacity(final BuildContext context) => Theme.of(context).brightness == Brightness.light ? 0.2 : 0.1; | ||
|
||
@override | ||
Widget build(final BuildContext context) { | ||
if (theme == null) { | ||
return ColoredBox( | ||
color: Theme.of(context).colorScheme.background, | ||
child: child, | ||
); | ||
} | ||
|
||
if (theme?.backgroundPlain ?? true) { | ||
return ColoredBox( | ||
color: | ||
Color.lerp(HexColor(theme!.background), Theme.of(context).colorScheme.background, 1 - _opacity(context))!, | ||
child: child, | ||
); | ||
} | ||
|
||
final image = NeonUrlImage( | ||
url: theme!.background, | ||
fit: BoxFit.fill, | ||
); | ||
return ColoredBox( | ||
color: Theme.of(context).colorScheme.background, | ||
child: Stack( | ||
children: [ | ||
Positioned.fill( | ||
child: Opacity( | ||
opacity: _opacity(context), | ||
child: image, | ||
), | ||
), | ||
if (child != null) child!, | ||
], | ||
), | ||
); | ||
} | ||
} |