Skip to content

Commit

Permalink
Merge pull request #17 from Iconica-Development/bugfix/pages
Browse files Browse the repository at this point in the history
fix: page overflow
  • Loading branch information
Gorter-dev authored Oct 2, 2024
2 parents 9abeb95 + 43385f3 commit fb9dce2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:settings_repository_interface/settings_repository_interface.dart';
import "package:cloud_firestore/cloud_firestore.dart";
import "package:firebase_auth/firebase_auth.dart";
import "package:settings_repository_interface/settings_repository_interface.dart";

class FirebaseSettingsRepository implements SettingsRepositoryInterface {
final String usersCollection;
Map<String, dynamic> _settingsMap = {};

FirebaseSettingsRepository({
this.usersCollection = 'users',
this.usersCollection = "users",
FirebaseFirestore? firestore,
}) : firestore = firestore ?? FirebaseFirestore.instance;
final String usersCollection;
Map<String, dynamic> _settingsMap = {};

final FirebaseFirestore firestore;

@override
Future<void> loadSettings() async {
try {
var userId = FirebaseAuth.instance.currentUser!.uid;
DocumentSnapshot<Map<String, dynamic>> snapshot =
var snapshot =
await firestore.collection(usersCollection).doc(userId).get();

if (snapshot.exists && snapshot.data() != null) {
_settingsMap = snapshot.data()!['settings'] ?? {};
_settingsMap = snapshot.data()!["settings"] ?? {};
} else {
_settingsMap = {};
}
} catch (e) {
print('Error loading settings: $e');
throw Exception('Failed to load settings');
} on Exception catch (e) {
print("Error loading settings: $e");
throw Exception("Failed to load settings");
}
}

Expand All @@ -38,12 +37,12 @@ class FirebaseSettingsRepository implements SettingsRepositoryInterface {
await firestore
.collection(usersCollection)
.doc(userId)
.set({'settings': settings}, SetOptions(merge: true));
.set({"settings": settings}, SetOptions(merge: true));

_settingsMap.addAll(settings);
} catch (e) {
print('Error saving settings: $e');
throw Exception('Failed to save settings');
print("Error saving settings: $e");
throw Exception("Failed to save settings");
}
}

Expand Down
12 changes: 6 additions & 6 deletions packages/firebase_settings_repository/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: firebase_settings_repository
description: "Firebase repository for flutter_settings"
version: 6.0.0
version: 6.0.1
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/

environment:
sdk: ^3.5.1
flutter: ">=1.17.0"

dependencies:
firebase_core: ^3.4.1
firebase_auth: ^4.19.4
flutter:
sdk: flutter
firebase_core: ^3.6.0
firebase_auth: ^5.3.1
cloud_firestore: ^5.4.3
settings_repository_interface:
path: ../settings_repository_interface

cloud_firestore: ^4.13.1
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
version: ^6.0.1

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class _InputFieldGeneratorState extends State<InputFieldGenerator> {
initialValue: (setting.value as Map)["selected"],
onChanged: (value) {
if (value != null) {
setting.onChange?.call(value.value);
setting.onChange?.call({setting.key: value.value});
widget.onUpdate(
() => (setting.value as Map)["selected"] = value.value,
);
Expand Down Expand Up @@ -546,41 +546,35 @@ class _InputFieldGeneratorState extends State<InputFieldGenerator> {
),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 20,
),
padding: const EdgeInsets.symmetric(vertical: 20),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
if (setting.prefixIcon != null) ...[
SizedBox(
width: 64,
child: setting.prefixIcon,
),
] else ...[
const SizedBox(width: 20),
if (setting.prefixIcon != null) ...[
SizedBox(
width: 64,
child: setting.prefixIcon,
),
] else ...[
const SizedBox(width: 20),
],
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (setting.title != null)
Text(
setting.title!,
style: theme.textTheme.titleMedium,
overflow: TextOverflow.ellipsis,
),
if (setting.description != null)
Text(
setting.description!,
style: theme.textTheme.bodyMedium,
overflow: TextOverflow.ellipsis,
),
],
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (setting.title != null)
Text(
setting.title!,
style: theme.textTheme.titleMedium,
),
if (setting.description != null)
Text(
setting.description!,
style: theme.textTheme.bodyMedium,
),
],
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
Expand All @@ -589,6 +583,7 @@ class _InputFieldGeneratorState extends State<InputFieldGenerator> {
],
),
),

),
);
}
Expand Down
6 changes: 4 additions & 2 deletions packages/flutter_settings/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_settings
description: "A new Flutter package project."
version: 6.0.0
version: 6.0.1
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/

environment:
Expand All @@ -14,7 +14,9 @@ dependencies:
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
version: ^3.6.0
settings_repository_interface:
path: ../settings_repository_interface
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
version: ^6.0.1
intl: ^0.19.0

dev_dependencies:
flutter_test:
Expand Down
2 changes: 1 addition & 1 deletion packages/settings_repository_interface/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: settings_repository_interface
description: "flutter_settings respository interface"
version: 6.0.0
version: 6.0.1
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/

environment:
Expand Down

0 comments on commit fb9dce2

Please sign in to comment.