Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
applicationId = "com.example.the_wallpaper_company"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = 23
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
Expand Down Expand Up @@ -60,4 +60,4 @@ dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")

// Other dependencies for your project...
}
}
110 changes: 64 additions & 46 deletions lib/features/home/presentation/screen/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import 'package:the_wallpaper_company/features/home/presentation/widgets/wallpap
import 'package:the_wallpaper_company/features/home/provider/wallpaper_provider.dart';
import 'package:the_wallpaper_company/firebase_message.dart';
import '../widgets/category_carousel.dart';
import '../widgets/search_bar_widget.dart';
import '../widgets/no_results_widget.dart';
import 'package:the_wallpaper_company/core/constants.dart';
import 'package:the_wallpaper_company/features/home/presentation/widgets/wallpaper_tile.dart';
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';
Expand Down Expand Up @@ -121,60 +123,76 @@ class _HomeScreenState extends State<HomeScreen> {
sigmaX: 12,
sigmaY: 12,
),
child: CategoryCarousel(
categories: AppConstants.categories,
selectedCategory:
provider.selectedCategory,
onCategorySelected:
provider.selectCategory,
child: Column(
children: [
const SearchBarWidget(),
CategoryCarousel(
categories:
AppConstants.categories,
selectedCategory:
provider.selectedCategory,
onCategorySelected:
provider.selectCategory,
),
],
),
),
),
),
// expandedHeight: 72,
toolbarHeight: 150,
toolbarHeight: 220,
),
SliverPadding(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 8,
),
sliver: SliverMasonryGrid.count(
crossAxisCount: 2,
mainAxisSpacing: 8,
crossAxisSpacing: 8,
childCount:
visibleWallpapers.length +
(provider.isPaginating ? 1 : 0),
itemBuilder: (context, index) {
if (provider.isPaginating &&
index == visibleWallpapers.length) {
return const WallpaperShimmer();
}
final wallpaper =
visibleWallpapers[index];
return InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
WallpaperScreen(
wallpapers:
visibleWallpapers,
initialIndex: index,
visibleWallpapers.isEmpty &&
provider.searchQuery.isNotEmpty
? SliverFillRemaining(
child: NoResultsWidget(
searchQuery: provider.searchQuery,
onClearSearch: provider.clearSearch,
),
)
: SliverPadding(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 8,
),
sliver: SliverMasonryGrid.count(
crossAxisCount: 2,
mainAxisSpacing: 8,
crossAxisSpacing: 8,
childCount:
visibleWallpapers.length +
(provider.isPaginating ? 1 : 0),
itemBuilder: (context, index) {
if (provider.isPaginating &&
index ==
visibleWallpapers
.length) {
return const WallpaperShimmer();
}
final wallpaper =
visibleWallpapers[index];
return InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
WallpaperScreen(
wallpapers:
visibleWallpapers,
initialIndex: index,
),
),
),
);
},
child: WallpaperTile(
imageUrl: wallpaper.imageUrl,
title: wallpaper.title,
id: wallpaper.id,
);
},
child: WallpaperTile(
imageUrl: wallpaper.imageUrl,
title: wallpaper.title,
id: wallpaper.id,
),
);
},
),
);
},
),
),
),
],
),
),
Expand Down
68 changes: 68 additions & 0 deletions lib/features/home/presentation/widgets/no_results_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import 'package:flutter/material.dart';

class NoResultsWidget extends StatelessWidget {
final String searchQuery;
final VoidCallback onClearSearch;

const NoResultsWidget({
super.key,
required this.searchQuery,
required this.onClearSearch,
});

@override
Widget build(BuildContext context) {
return Center(
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.search_off,
size: 64,
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[600]
: Colors.grey[400],
),
const SizedBox(height: 16),
Text(
'No wallpapers found',
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[400]
: Colors.grey[600],
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
Text(
'No results for "${searchQuery.trim()}"',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[500]
: Colors.grey[500],
),
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
ElevatedButton.icon(
onPressed: onClearSearch,
icon: const Icon(Icons.clear),
label: const Text('Clear Search'),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 12,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25),
),
),
),
],
),
),
);
}
}
105 changes: 105 additions & 0 deletions lib/features/home/presentation/widgets/search_bar_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../provider/wallpaper_provider.dart';

class SearchBarWidget extends StatefulWidget {
const SearchBarWidget({super.key});

@override
State<SearchBarWidget> createState() => _SearchBarWidgetState();
}

class _SearchBarWidgetState extends State<SearchBarWidget> {
final TextEditingController _searchController = TextEditingController();
final FocusNode _focusNode = FocusNode();

@override
void initState() {
super.initState();
final provider = Provider.of<WallpaperProvider>(context, listen: false);
_searchController.text = provider.searchQuery;
}

@override
void dispose() {
_searchController.dispose();
_focusNode.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Consumer<WallpaperProvider>(
builder: (context, provider, child) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[800]?.withValues(alpha: 0.8)
: Colors.white.withValues(alpha: 0.8),
borderRadius: BorderRadius.circular(25),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.1),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: TextField(
controller: _searchController,
focusNode: _focusNode,
onChanged: (value) {
provider.updateSearchQuery(value);
},
decoration: InputDecoration(
hintText: 'Search wallpapers by title or category...',
hintStyle: TextStyle(
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[400]
: Colors.grey[600],
fontSize: 16,
),
prefixIcon: Icon(
provider.searchQuery.isNotEmpty ? Icons.search : Icons.search,
color: provider.searchQuery.isNotEmpty
? Colors.pinkAccent
: (Theme.of(context).brightness == Brightness.dark
? Colors.grey[400]
: Colors.grey[600]),
size: 24,
),
suffixIcon: provider.searchQuery.isNotEmpty
? IconButton(
icon: Icon(
Icons.clear,
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[400]
: Colors.grey[600],
size: 20,
),
onPressed: () {
_searchController.clear();
provider.clearSearch();
_focusNode.unfocus();
},
)
: null,
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 16,
),
),
style: TextStyle(
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black87,
fontSize: 16,
),
),
);
},
);
}
}
Loading
Loading