Skip to content
This repository was archived by the owner on Jul 17, 2025. It is now read-only.
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
8 changes: 8 additions & 0 deletions lib/controllers/camera_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ import 'package:openwardrobe/repositories/app_repository.dart';
class CameraController {
final AppRepository _appRepository = GetIt.instance<AppRepository>();

List<File> _selectedImages = [];
List<Uint8List> _selectedWebImages = [];

Future<List<File>> pickImages({bool fromGallery = false}) async {
_selectedImages.clear();
_selectedWebImages.clear();

if (kIsWeb) {
final result = await FilePicker.platform.pickFiles(
type: FileType.image,
allowMultiple: true,
);

if (result != null && result.files.isNotEmpty) {
_selectedWebImages = result.files.map((file) => file.bytes!).toList();
return result.files.map((file) => File(file.path!)).toList();
} else {
throw Exception('No images selected');
Expand All @@ -27,6 +34,7 @@ class CameraController {
);

if (pickedFile != null) {
_selectedImages = [File(pickedFile.path)];
return [File(pickedFile.path)];
} else {
throw Exception('No image selected');
Expand Down
2 changes: 2 additions & 0 deletions lib/controllers/settings_account_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class SettingsAccountController {
);

if (pickedFile != null) {
_selectedImages.clear();
return File(pickedFile.path);
} else {
return null;
Expand All @@ -68,6 +69,7 @@ class SettingsAccountController {
);

if (pickedFile != null) {
_selectedWebImages.clear();
return await pickedFile.readAsBytes();
} else {
return null;
Expand Down
2 changes: 1 addition & 1 deletion lib/presentation/blocs/camera/camera_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ class CameraCubit extends Cubit<CameraState> {
}
return super.close();
}
}
}
3 changes: 2 additions & 1 deletion lib/ui/screens/camera/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ Future<void> _submitImages() async {

@override
void dispose() {
context.read<CameraCubit>().close();
super.dispose();
}

Expand Down Expand Up @@ -269,4 +270,4 @@ Future<void> _submitImages() async {
),
);
}
}
}
108 changes: 61 additions & 47 deletions lib/ui/screens/lookbook/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,73 @@ import 'package:openwardrobe/presentation/blocs/lookbook/lookbook_cubit.dart';
import 'package:openwardrobe/presentation/blocs/lookbook/lookbook_state.dart';
import 'package:openwardrobe/ui/widgets/lookbook/lookbook_component.dart';

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

@override
_LookbookScreenState createState() => _LookbookScreenState();
}

class _LookbookScreenState extends State<LookbookScreen> {
@override
void initState() {
super.initState();
context.read<LookbookCubit>().fetchLookbookItems();
}

@override
void dispose() {
context.read<LookbookCubit>().close();
super.dispose();
}

@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => LookbookCubit()..fetchLookbookItems(),
child: Scaffold(
appBar: AppBar(
title: const Text('Lookbook'),
),
body: SingleChildScrollView(
child: IntrinsicHeight(
child: Align(
alignment: Alignment.topCenter,
child: Column(
children: [
const SizedBox(height: 20),
Expanded(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 500),
child: BlocBuilder<LookbookCubit, LookbookState>(
builder: (context, state) {
return switch (state) {
LookbookLoading() => const Center(
child: CircularProgressIndicator(),
),
LookbookError(message: var message) => Center(
child: Text('Error: $message'),
),
LookbookLoaded(lookbookItems: final items) => items.isEmpty
? const Center(child: Text('No items found'))
: SingleChildScrollView(
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
alignment: WrapAlignment.start,
children: items.map((item) => Container(
width: 150,
child: LookbookComponent(item: item),
)).toList(),
),
return Scaffold(
appBar: AppBar(
title: const Text('Lookbook'),
),
body: SingleChildScrollView(
child: IntrinsicHeight(
child: Align(
alignment: Alignment.topCenter,
child: Column(
children: [
const SizedBox(height: 20),
Expanded(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 500),
child: BlocBuilder<LookbookCubit, LookbookState>(
builder: (context, state) {
return switch (state) {
LookbookLoading() => const Center(
child: CircularProgressIndicator(),
),
LookbookError(message: var message) => Center(
child: Text('Error: $message'),
),
LookbookLoaded(lookbookItems: final items) => items.isEmpty
? const Center(child: Text('No items found'))
: SingleChildScrollView(
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
alignment: WrapAlignment.start,
children: items.map((item) => Container(
width: 150,
child: LookbookComponent(item: item),
)).toList(),
),
LookbookInitial() => const Center(
child: CircularProgressIndicator(),
),
};
},
),
),
LookbookInitial() => const Center(
child: CircularProgressIndicator(),
),
};
},
),
)
],
),
),
)
],
),
),
),
Expand Down
85 changes: 47 additions & 38 deletions lib/ui/screens/settings/page.dart
Original file line number Diff line number Diff line change
@@ -1,54 +1,63 @@
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';

class SettingsScreen extends StatelessWidget {
class SettingsScreen extends StatefulWidget {
const SettingsScreen({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
_SettingsScreenState createState() => _SettingsScreenState();
}

class _SettingsScreenState extends State<SettingsScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Settings'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Settings',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
ListTile(
title: const Text('Account'),
onTap: () {
// Navigate to account settings
},
),
ListTile(
title: const Text('Notifications'),
onTap: () {
// Navigate to notification settings
},
),
ListTile(
title: const Text('Privacy'),
onTap: () {
// Navigate to privacy settings
},
),
ListTile(
title: const Text('About'),
onTap: () {
// Navigate to about page
},
),
],
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Settings',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
ListTile(
title: const Text('Account'),
onTap: () {
// Navigate to account settings
},
),
ListTile(
title: const Text('Notifications'),
onTap: () {
// Navigate to notification settings
},
),
)
ListTile(
title: const Text('Privacy'),
onTap: () {
// Navigate to privacy settings
},
),
ListTile(
title: const Text('About'),
onTap: () {
// Navigate to about page
},
),
],
),
),
);

}

@override
void dispose() {
// Dispose of any resources or controllers to prevent memory leaks
super.dispose();
}
}
8 changes: 8 additions & 0 deletions lib/ui/screens/wardrobe/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class _WardrobeScreenState extends State<WardrobeScreen> {
]);
}

@override
void dispose() {
// Dispose of any resources or controllers to prevent memory leaks
context.read<CategoryCubit>().close();
context.read<WardrobeCubit>().close();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
8 changes: 8 additions & 0 deletions lib/ui/screens/wardrobe/settings/account_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class _SettingsAccountPageState extends State<SettingsAccountPage> {
_userProfileFuture = _controller.fetchUserProfile();
}

@override
void dispose() {
_usernameController.dispose();
_displayNameController.dispose();
_bioController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
32 changes: 22 additions & 10 deletions lib/ui/screens/wardrobe_item/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,34 @@ import 'package:collection/collection.dart';
import 'package:openwardrobe/presentation/blocs/category/category_cubit.dart'; // Added import
import 'package:openwardrobe/presentation/blocs/category/category_state.dart'; // Added import

class WardrobeItemPage extends StatelessWidget {
class WardrobeItemPage extends StatefulWidget {
final String itemId;

const WardrobeItemPage({super.key, required this.itemId});

@override
_WardrobeItemPageState createState() => _WardrobeItemPageState();
}

class _WardrobeItemPageState extends State<WardrobeItemPage> {
late WardrobeItemCubit _wardrobeItemCubit;

@override
void initState() {
super.initState();
_wardrobeItemCubit = WardrobeItemCubit()..loadWardrobeItem(widget.itemId);
}

@override
void dispose() {
_wardrobeItemCubit.close();
super.dispose();
}

@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => WardrobeItemCubit()..loadWardrobeItem(itemId),
),
BlocProvider(
create: (context) => CategoryCubit()..loadCategories('userId'), // Replace 'userId' with actual userId
),
],
return BlocProvider(
create: (context) => _wardrobeItemCubit,
child: Scaffold(
appBar: AppBar(
title: const Text('Wardrobe Item'),
Expand Down