Skip to content

Commit 582f517

Browse files
authored
Merge pull request #31 from sumit-coder/ui_work
UI work
2 parents 7ea3d18 + 20202da commit 582f517

38 files changed

+536
-639
lines changed

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cSpell.words": [
3+
"appwrite",
4+
"cupertino"
5+
]
6+
}

assets/images/saved-poster.png

43.9 KB
Loading
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
class AppWriteConst {
2-
static const String APPWRITE_PROJECT_ID = "64803e0044c9826d779b";
3-
static const String APPWRITE_ENDPOINT = "https://cloud.appwrite.io/v1";
4-
static const String APPWRITE_DATABASE_ID = "";
5-
static const String COLLECTION_MESSAGES = "";
2+
static const String APPWRITE_PROJECT_ID = '';
3+
static const String APPWRITE_ENDPOINT = 'https://cloud.appwrite.io/v1';
64

75
// databases
8-
// static const usersDataDatabaseID = '648450950ccd47af09ca';
6+
static const publicDataDatabaseID = '';
7+
static const usersDataDatabaseID = '';
8+
9+
// collections
10+
static const designResourcesCollectionId = '';
11+
static const savedComponentsCollectionId = '';
12+
static const savedComponentsId = '';
13+
static const savedSnippetCollectionId = '';
14+
static const savedSnippetId = '';
15+
static const savedDesignResourcesId = '';
16+
//
17+
static const inspirationsFilesCollectionID = '';
18+
// storage
19+
static const usersInspirationFilesBucketId = '';
20+
static const usersComponentsPreviewFilesBucketId = '';
21+
22+
// NOTE: all of this empty because this is public
923
}

lib/appwrite_service/auth_service.dart

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class AuthService extends ChangeNotifier {
3434
AuthStatus get status => _status;
3535
String? get username => _currentUser.name;
3636
String? get email => _currentUser.email;
37-
String? get userid => _currentUser.$id;
37+
String? get userId => _currentUser.$id;
3838

3939
// Constructor
4040
AuthService() {
@@ -60,14 +60,16 @@ class AuthService extends ChangeNotifier {
6060
}
6161
}
6262

63-
Future<User> createUser({required String email, required String password}) async {
63+
Future<User?> createUser({required String email, required String password}) async {
6464
notifyListeners();
6565

6666
try {
67-
final user = await account.create(userId: ID.unique(), email: email, password: password, name: 'Sam Alt');
67+
final user = await account.create(userId: ID.unique(), email: email, password: password);
6868
return user;
69-
} finally {
70-
notifyListeners();
69+
} on AppwriteException catch (e) {
70+
print(e);
71+
UtilityHelper.toastMessage(message: e.message ?? "AuthService.createUser() null message");
72+
return null;
7173
}
7274
}
7375

@@ -119,12 +121,4 @@ class AuthService extends ChangeNotifier {
119121
notifyListeners();
120122
}
121123
}
122-
123-
Future<Preferences> getUserPreferences() async {
124-
return await account.getPrefs();
125-
}
126-
127-
updatePreferences({required String bio}) async {
128-
return account.updatePrefs(prefs: {'bio': bio});
129-
}
130124
}

lib/appwrite_service/databases_service.dart

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import 'dart:convert';
21
import 'dart:developer';
32

43
import 'package:appwrite/appwrite.dart';
54
import 'package:appwrite/models.dart';
6-
// import 'package:help_me_design/appwrite_service/appwrite_constants.dart';
75
import 'package:help_me_design/models/design_resources_model.dart';
8-
import 'package:help_me_design/providers/snippet_tab_provider.dart';
96
import 'package:help_me_design/utility/utility_helper.dart';
10-
import 'package:help_me_design/views/screens/tabs/components_tab/widgets/add_component_collection_alert.dart';
117

128
import 'appwrite_constants_all.dart';
139

@@ -171,6 +167,37 @@ class Example{
171167
return false;
172168
}
173169
}
170+
171+
Future<bool> saveDesignResource({
172+
required String userId,
173+
required String url,
174+
required String title,
175+
required String description,
176+
required String originalResourceId,
177+
}) async {
178+
final databases = Databases(client);
179+
try {
180+
final document = await databases.createDocument(
181+
databaseId: AppWriteConst.usersDataDatabaseID,
182+
collectionId: AppWriteConst.savedDesignResourcesId,
183+
documentId: ID.unique(),
184+
data: {
185+
"title": title,
186+
"url": url,
187+
"userId": userId,
188+
"description": description,
189+
"originalResourceId": originalResourceId,
190+
},
191+
);
192+
UtilityHelper.toastMessage(message: "Design Resource Saved");
193+
194+
return true;
195+
} on AppwriteException catch (e) {
196+
UtilityHelper.toastMessage(message: e.message ?? "add.saveDesignResource() null message");
197+
log(e.toString());
198+
return false;
199+
}
200+
}
174201
}
175202

176203
class Get {
@@ -277,6 +304,26 @@ class Get {
277304
return [];
278305
}
279306
}
307+
308+
Future<List<Document>> savedDesignResource({required String userId}) async {
309+
final databases = Databases(client);
310+
try {
311+
final data = await databases.listDocuments(
312+
databaseId: AppWriteConst.usersDataDatabaseID,
313+
collectionId: AppWriteConst.savedDesignResourcesId,
314+
queries: [
315+
Query.equal('userId', userId),
316+
Query.orderDesc('\$createdAt'),
317+
],
318+
);
319+
log("Get.savedDesignResource");
320+
return data.documents;
321+
} on AppwriteException catch (e) {
322+
print(e);
323+
UtilityHelper.toastMessage(message: e.message ?? "get.savedDesignResource() null message");
324+
return [];
325+
}
326+
}
280327
}
281328

282329
class Update {
@@ -365,14 +412,24 @@ class DeleteData {
365412
return false;
366413
}
367414
}
368-
}
369415

370-
String code = ''' Positioned(
371-
top: 8,
372-
left: 8,
373-
child: Text(
374-
"Preview",
375-
maxLines: 2,
376-
style: themeData.textTheme.titleSmall,
377-
),
378-
),''';
416+
Future<bool> savedDesignResource({
417+
required String docId,
418+
}) async {
419+
final databases = Databases(client);
420+
try {
421+
final data = await databases.deleteDocument(
422+
databaseId: AppWriteConst.usersDataDatabaseID,
423+
collectionId: AppWriteConst.savedDesignResourcesId,
424+
documentId: docId,
425+
);
426+
log("Delete.savedDesignResource");
427+
428+
return true;
429+
} on AppwriteException catch (e) {
430+
print(e);
431+
UtilityHelper.toastMessage(message: e.message ?? "delete.savedDesignResource() null message");
432+
return false;
433+
}
434+
}
435+
}

lib/constants/text_constants.dart

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
class MyTextConstants {
2-
/// Docs Tab
2+
/// Docs Tab (this tab is not done yet)
33
static const String docsTabHeadline = 'Explore. Documentation\'s';
4-
static const String docsTabShortDescription =
5-
'Welcome to HelpMeDesign, \nHere you can Explore, Add & Create. Design Resources, Design Systems, UI Components etc.';
4+
static const String docsTabShortDescription = 'Docs Tab,';
5+
6+
/// Explore Tab
7+
static const String exploreTabHeadline = 'Explore.';
8+
static const String exploreTabShortDescription =
9+
'Welcome to HelpMeDesign, \nHere you can Explore & Save. Design Resources, Code Ui Components, Code Snippets etc.';
10+
11+
/// Inspirations Tab
12+
static const String inspirationsTabHeadline = 'Inspirations.';
13+
static const String inspirationTabShortDescription = 'Save Your Design Inspirations Here.';
14+
15+
/// Components Tab
16+
static const String componentsTabHeadline = 'Components.';
17+
static const String componentsTabShortDescription = 'Component, component, and components add them all here.';
18+
19+
/// Snippets Tab
20+
static const String snippetsTabHeadline = 'Code Snippet.';
21+
static const String snippetsTabShortDescription = 'World of Code Snippets, You can save your snippets here.';
22+
23+
/// Saved Tab
24+
static const String savedTabHeadline = 'Saved.';
25+
static const String savedTabShortDescription = 'Your saved Design Resources will live here.';
626
}

lib/main.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import 'package:provider/provider.dart';
1010

1111
import 'constants/app_constants.dart';
1212
import 'providers/inspiration_tab_provider/inspiration_tab_provider.dart';
13-
import 'providers/snippet_tab_provider.dart';
13+
import 'providers/saved_tab_provider/saved_tab_provider.dart';
14+
import 'providers/snippet_tab_provider/snippet_tab_provider.dart';
1415
import 'views/screens/home_screen/home_screen.dart';
1516

1617
import 'package:url_strategy/url_strategy.dart';
@@ -34,11 +35,12 @@ class _MyAppState extends State<MyApp> {
3435
return MultiProvider(
3536
providers: [
3637
ChangeNotifierProvider<ThemeManager>(create: (_) => ThemeManager()),
37-
ChangeNotifierProvider<SnippetTabProvider>(create: (_) => SnippetTabProvider()),
38-
ChangeNotifierProvider<ComponentTabProvider>(create: (_) => ComponentTabProvider()),
3938
ChangeNotifierProvider<AuthService>(create: (_) => AuthService()),
4039
ChangeNotifierProvider<ExploreTabProvider>(create: (_) => ExploreTabProvider()),
4140
ChangeNotifierProvider<InspirationTabProvider>(create: (_) => InspirationTabProvider()),
41+
ChangeNotifierProvider<ComponentTabProvider>(create: (_) => ComponentTabProvider()),
42+
ChangeNotifierProvider<SnippetTabProvider>(create: (_) => SnippetTabProvider()),
43+
ChangeNotifierProvider<SavedTabProvider>(create: (_) => SavedTabProvider()),
4244
],
4345
child: Consumer2<ThemeManager, AuthService>(builder: (context, themeManagerProvider, authServiceProvider, snapshot) {
4446
return MaterialApp(
@@ -55,7 +57,7 @@ class _MyAppState extends State<MyApp> {
5557
? const SignInSignUpScreen()
5658
: authServiceProvider.status == AuthStatus.authenticated
5759
? const MyHomePage()
58-
: WelcomeScreen(),
60+
: const WelcomeScreen(),
5961
// home: WelcomeScreen(),
6062
);
6163
}),
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'package:appwrite/models.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:help_me_design/appwrite_service/databases_service.dart';
4+
5+
class SavedTabProvider with ChangeNotifier {
6+
List<Document> listOfSavedDesignResources = [];
7+
8+
getSavedDesignResources(String userId) async {
9+
listOfSavedDesignResources = await DatabasesService.get.savedDesignResource(userId: userId);
10+
11+
notifyListeners();
12+
}
13+
}

lib/providers/snippet_tab_provider.dart renamed to lib/providers/snippet_tab_provider/snippet_tab_provider.dart

File renamed without changes.

lib/views/screens/home_screen/home_screen.dart

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_animate/flutter_animate.dart';
33
import 'package:help_me_design/views/screens/tabs/components_tab/components_tab.dart';
44
import 'package:help_me_design/views/screens/tabs/inspiration_tab/inspiration_tab.dart';
5+
import 'package:help_me_design/views/screens/tabs/saved_tab/saved_tab.dart';
56
import 'package:help_me_design/views/screens/tabs/settings_tab/settings_tab.dart';
67

7-
import '../tabs/categories_screens.dart';
88
import '../tabs/code_snippet_tab/code_snippet_tab.dart';
9-
import '../tabs/docs_tab/docs_tab.dart';
109
import '../tabs/explore_tab/explore_tab.dart';
1110
import 'widgets/admin_view_sidebar.dart';
1211

@@ -27,19 +26,25 @@ class _MyHomePageState extends State<MyHomePage> {
2726
Widget switchTabs(SideTabType newActiveTab) {
2827
switch (newActiveTab) {
2928
case SideTabType.explore:
30-
return ExploreView();
29+
return const ExploreView();
30+
3131
case SideTabType.inspiration:
32-
return InspirationTab();
33-
// case SideTabType.docs:
34-
// return DocsView();
35-
case SideTabType.codeSnippet:
36-
return CodeSnippetScreen();
32+
return const InspirationTab();
33+
3734
case SideTabType.components:
3835
return const ComponentsTab();
36+
37+
case SideTabType.codeSnippet:
38+
return CodeSnippetScreen();
39+
40+
case SideTabType.saved:
41+
return const SavedDesignResourceTab();
42+
3943
case SideTabType.settings:
4044
return const SettingsTab();
45+
4146
default:
42-
return const CategoriesView();
47+
return const ExploreView();
4348
}
4449
}
4550

0 commit comments

Comments
 (0)