-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bd5ae4
commit 77023b8
Showing
9 changed files
with
200 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
|
||
## 1.2.0 | ||
|
||
- enable to select a local background image |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,67 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:fluent_ui/fluent_ui.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:smart_watch_widget/pages/background/backgroundItem.dart'; | ||
import 'package:smart_watch_widget/state/appState.dart'; | ||
|
||
class BackgroundImageItem extends StatefulWidget { | ||
final bool isSelected; | ||
final void Function() onPressed; | ||
|
||
const BackgroundImageItem( | ||
{Key? key, required this.isSelected, required this.onPressed}) | ||
: super(key: key); | ||
|
||
@override | ||
State<BackgroundImageItem> createState() => _BackgroundImageItemState(); | ||
} | ||
|
||
class _BackgroundImageItemState extends State<BackgroundImageItem> | ||
with SingleTickerProviderStateMixin { | ||
late Animation<double> animation; | ||
late AnimationController controller; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
controller = AnimationController( | ||
duration: const Duration(milliseconds: 75), vsync: this); | ||
final Animation<double> curve = | ||
CurvedAnimation(parent: controller, curve: Curves.easeIn); | ||
animation = Tween<double>(begin: 0.8, end: 0.9).animate(curve); | ||
} | ||
|
||
final fit = BoxFit.fill; | ||
final colorBlendMode = BlendMode.modulate; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MouseRegion( | ||
onEnter: (_) => controller.forward(), | ||
onExit: (_) => controller.reverse(), | ||
child: BackgroundItem( | ||
name: 'Image', | ||
background: AnimatedBuilder( | ||
animation: animation, | ||
builder: (context, child) { | ||
return context.watch<AppState>().background == | ||
Background.localImage && | ||
context.watch<AppState>().localImageBackground != null | ||
? Image.file( | ||
File(context.watch<AppState>().localImageBackground!), | ||
fit: fit, | ||
color: Colors.white.withOpacity(animation.value), | ||
colorBlendMode: colorBlendMode) | ||
: Image.asset('assets/images/tulips-100_150.png', | ||
fit: fit, | ||
color: Colors.white.withOpacity(animation.value), | ||
colorBlendMode: colorBlendMode); | ||
}, | ||
), | ||
isSelected: widget.isSelected, | ||
onPressed: widget.onPressed, | ||
), | ||
); | ||
} | ||
} |
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