diff --git a/lib/feature/search_view.dart b/lib/feature/search/search_view.dart similarity index 100% rename from lib/feature/search_view.dart rename to lib/feature/search/search_view.dart diff --git a/lib/feature/user/view/user_view.dart b/lib/feature/user/view/user_view.dart index 21faa50..d6f2585 100644 --- a/lib/feature/user/view/user_view.dart +++ b/lib/feature/user/view/user_view.dart @@ -5,7 +5,7 @@ import 'package:flutter_clean_app_examples/feature/user/view_model/user_view_mod import 'package:hive_flutter/hive_flutter.dart'; import 'package:provider/provider.dart'; -import '../../search_view.dart'; +import '../../search/search_view.dart'; import '../model/user_model.dart'; class UserViewWidget extends StatefulWidget { @@ -19,7 +19,7 @@ class _UserViewWidgetState extends State { late UserViewModel userViewModel; late final ICacheManager cacheManager; List? _items; - + @override void initState() { super.initState(); @@ -30,53 +30,53 @@ class _UserViewWidgetState extends State { } Future fetchDatasInit() async { - await cacheManager.init(); + await cacheManager.init(); if (cacheManager.getValues()?.isNotEmpty ?? false) { _items = cacheManager.getValues(); - print("cache dolu "); - }else{ - - _items= userViewModel.userViewModelList; - print("cache boş "); + } else { + _items = userViewModel.userViewModelList; } setState(() {}); } @override Widget build(BuildContext context) { - return cacheManager.getValues()!.isNotEmpty ? - bodyView(context): - ChangeNotifierProvider.value( - value: userViewModel, - child: Consumer( - builder: ((context, value, child) => bodyViewProvider(context))), - ); + return cacheManager.getValues()!.isNotEmpty + ? bodyView(context) + : ChangeNotifierProvider.value( + value: userViewModel, + child: Consumer( + builder: ((context, value, child) => + bodyViewProvider(context))), + ); } Scaffold bodyView(BuildContext context) { - print("sükür"); return Scaffold( appBar: AppBar( - actions: [IconButton(onPressed: (){ - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => SearchView(model: cacheManager,), - ), - ); - }, icon: Icon(CupertinoIcons.search))], + actions: [ + IconButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => SearchView( + model: cacheManager, + ), + ), + ); + }, + icon: Icon(CupertinoIcons.search)) + ], title: const Text("Users"), centerTitle: true, ), - floatingActionButton: FloatingActionButton( - - onPressed: () async { - cacheManager.getValues(); + floatingActionButton: FloatingActionButton(onPressed: () async { + cacheManager.getValues(); if (_items?.isNotEmpty ?? false) { await cacheManager.addItems(_items!); - } - }), + }), body: ListView.builder( itemCount: _items!.length, itemBuilder: ((context, index) { @@ -85,39 +85,39 @@ class _UserViewWidgetState extends State { leading: const CircleAvatar( child: Icon(Icons.account_circle_outlined), ), - title: Text( - '${_items?[index].name}'), + title: Text('${_items?[index].name}'), ), ); }), )); } - Scaffold bodyViewProvider(BuildContext context) { - print("üzdü"); return Scaffold( appBar: AppBar( - actions: [IconButton(onPressed: (){ - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => SearchView(model: cacheManager,), - ), - ); - }, icon: Icon(CupertinoIcons.search))], + actions: [ + IconButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => SearchView( + model: cacheManager, + ), + ), + ); + }, + icon: Icon(CupertinoIcons.search)) + ], title: const Text("Users"), centerTitle: true, ), - floatingActionButton: FloatingActionButton( - - onPressed: () async { - cacheManager.getValues(); + floatingActionButton: FloatingActionButton(onPressed: () async { + cacheManager.getValues(); if (_items?.isNotEmpty ?? false) { await cacheManager.addItems(_items!); - } - }), + }), body: ListView.builder( itemCount: _items!.length, itemBuilder: ((context, index) { @@ -126,8 +126,7 @@ class _UserViewWidgetState extends State { leading: const CircleAvatar( child: Icon(Icons.account_circle_outlined), ), - title: Text( - '${_items?[index].name}'), + title: Text('${_items?[index].name}'), ), ); }),