Skip to content

Commit

Permalink
add: watermark
Browse files Browse the repository at this point in the history
  • Loading branch information
athallahmaajid committed Dec 14, 2021
1 parent ac82661 commit e50ce7a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
29 changes: 26 additions & 3 deletions lib/view/detail_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:io';
import 'dart:isolate';
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
Expand All @@ -14,8 +13,9 @@ import 'package:wamo/model/wallpaper.dart';
class DetailPage extends StatefulWidget {
final String url;
final String tag;
String source;

DetailPage({Key? key, required this.url, required this.tag}) : super(key: key);
DetailPage({Key? key, required this.url, required this.tag, this.source = ""}) : super(key: key);

@override
State<DetailPage> createState() => _DetailPageState();
Expand Down Expand Up @@ -73,7 +73,19 @@ class _DetailPageState extends State<DetailPage> {
children: [
Stack(
children: [
Hero(tag: widget.tag, child: Image.network(widget.url)),
Hero(
tag: widget.tag,
child: Container(
height: MediaQuery.of(context).size.height * 0.9,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(widget.url),
fit: BoxFit.cover,
),
),
),
),
Positioned(
top: MediaQuery.of(context).size.height * 0.07,
left: MediaQuery.of(context).size.width * 0.06,
Expand All @@ -95,6 +107,16 @@ class _DetailPageState extends State<DetailPage> {
),
),
),
(widget.source != "")
? Positioned(
bottom: 10,
right: 10,
child: Text(
"Powered By ${widget.source}",
style: Theme.of(context).textTheme.bodyText1,
),
)
: Container(),
dialog(),
],
),
Expand Down Expand Up @@ -134,6 +156,7 @@ class _DetailPageState extends State<DetailPage> {
var status = await Permission.storage.request();
if (status.isGranted) {
String fileName = widget.url.replaceAll("https://images.wallpaperscraft.com/image/single/", "");
// ignore: unused_local_variable
final taskId = await FlutterDownloader.enqueue(
fileName: fileName,
url: widget.url,
Expand Down
14 changes: 11 additions & 3 deletions lib/view/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,17 @@ class _SearchPageState extends State<SearchPage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailPage(url: wallpaperLoaded.wallpapers![index].url, tag: index.toString()),
builder: (context) => DetailPage(
url: wallpaperLoaded.wallpapers![index].url,
tag: index.toString(),
source: "Wallpaper Abyss",
),
),
);
},
child: Hero(
tag: (index).toString(),
// child: Image.network(wallpaperLoaded.wallpapers![index].url)
child: Container(
height: 300,
width: 160,
Expand All @@ -149,8 +154,11 @@ class _SearchPageState extends State<SearchPage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
DetailPage(url: wallpaperLoaded.wallpapers![index + 1].url, tag: (index + 1).toString()),
builder: (context) => DetailPage(
url: wallpaperLoaded.wallpapers![index + 1].url,
tag: (index + 1).toString(),
source: "Wallpaper Abyss",
),
),
);
},
Expand Down

0 comments on commit e50ce7a

Please sign in to comment.