Skip to content

Commit

Permalink
[Fix] Book Store and Question Generation (#5)
Browse files Browse the repository at this point in the history
Co-authored-by: FlutterFlow <140657486+FlutterFlowEng@users.noreply.github.com>
  • Loading branch information
gemechis-elias and FlutterFlowEng authored Dec 8, 2024
1 parent 3f98a87 commit 13937d3
Show file tree
Hide file tree
Showing 52 changed files with 3,049 additions and 649 deletions.
Binary file added assets/images/81ANaVZk5LL._SL1500_.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/adaptive_foreground_icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/app_launcher_icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/image-27-1024x569.png
Binary file not shown.
Binary file not shown.
Binary file added assets/images/photo_2022-06-25_22-45-23.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/photo_2022-06-26_17-53-24.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/photo_2022-06-26_19-40-17.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/photo_2022-06-26_19-40-29.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/photo_2024-06-28_22-18-53.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pdfs/1730017179741.pdf
Binary file not shown.
692 changes: 353 additions & 339 deletions lib/components/activate_account_widget.dart

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
import 'package:webviewx_plus/webviewx_plus.dart';

class PostDetailsBaseModel extends FlutterFlowModel<PostDetailsBaseWidget> {
/// State fields for stateful widgets in this component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
import 'package:webviewx_plus/webviewx_plus.dart';
import 'post_details_base_model.dart';
export 'post_details_base_model.dart';

Expand Down Expand Up @@ -218,14 +219,16 @@ class _PostDetailsBaseWidgetState extends State<PostDetailsBaseWidget>
.accent4,
context: context,
builder: (context) {
return Padding(
padding: MediaQuery.viewInsetsOf(
context),
child: Container(
height: 230.0,
child: DeletePostWidget(
postParameters:
containerUserPostsRecord,
return WebViewAware(
child: Padding(
padding: MediaQuery.viewInsetsOf(
context),
child: Container(
height: 230.0,
child: DeletePostWidget(
postParameters:
containerUserPostsRecord,
),
),
),
);
Expand Down
1 change: 1 addition & 0 deletions lib/components/web_components/stories/stories_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:flutter_blurhash/flutter_blurhash.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:octo_image/octo_image.dart';
import 'package:provider/provider.dart';
import 'package:webviewx_plus/webviewx_plus.dart';

class StoriesModel extends FlutterFlowModel<StoriesWidget> {
/// State fields for stateful widgets in this component.
Expand Down
36 changes: 21 additions & 15 deletions lib/components/web_components/stories/stories_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:flutter_blurhash/flutter_blurhash.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:octo_image/octo_image.dart';
import 'package:provider/provider.dart';
import 'package:webviewx_plus/webviewx_plus.dart';
import 'stories_model.dart';
export 'stories_model.dart';

Expand Down Expand Up @@ -376,18 +377,20 @@ class _StoriesWidgetState extends State<StoriesWidget>
context,
builder:
(context) {
return Padding(
padding: MediaQuery
.viewInsetsOf(
context),
return WebViewAware(
child:
Container(
height:
240.0,
Padding(
padding:
MediaQuery.viewInsetsOf(context),
child:
DeleteStoryWidget(
storyDetails:
pageViewUserStoriesRecord,
Container(
height:
240.0,
child:
DeleteStoryWidget(
storyDetails:
pageViewUserStoriesRecord,
),
),
),
);
Expand Down Expand Up @@ -507,11 +510,14 @@ class _StoriesWidgetState extends State<StoriesWidget>
barrierColor: Color(0x00000000),
context: context,
builder: (context) {
return Padding(
padding: MediaQuery.viewInsetsOf(
context),
child: CommentsWidget(
story: pageViewUserStoriesRecord,
return WebViewAware(
child: Padding(
padding: MediaQuery.viewInsetsOf(
context),
child: CommentsWidget(
story:
pageViewUserStoriesRecord,
),
),
);
},
Expand Down
12 changes: 6 additions & 6 deletions lib/custom_code/actions/start_n_f_c_reading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ Future startNFCReading(BuildContext context) async {
NfcManager.instance.startSession(
onDiscovered: (NfcTag tag) async {
// Show a SnackBar with the detected tag data.
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('NFC Tag Detected: ${tag.data}')));
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(content: Text('NFC Tag Detected: ${tag.data}')));

// Optionally, stop the session after reading.
NfcManager.instance.stopSession();
},
);
} else {
// Show a SnackBar if NFC is not available.
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('NFC not available.')));
// ScaffoldMessenger.of(context)
// .showSnackBar(SnackBar(content: Text('NFC not available.')));
}
} catch (e) {
// Show a SnackBar for any errors.
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Error reading NFC: $e')));
// ScaffoldMessenger.of(context)
// .showSnackBar(SnackBar(content: Text('Error reading NFC: $e')));
}
}
12 changes: 6 additions & 6 deletions lib/custom_code/actions/start_n_f_c_writing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ Future startNFCWriting(
await Ndef.from(tag)?.write(message);

// Show a SnackBar notification for successful write.
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Data emitted successfully')));
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(content: Text('Data emitted successfully')));

Uint8List payload = message.records.first.payload;
String text = String.fromCharCodes(payload);

// Show a SnackBar with written data.
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Written data: $text')));
// ScaffoldMessenger.of(context)
// .showSnackBar(SnackBar(content: Text('Written data: $text')));

// Stop the NFC session.
NfcManager.instance.stopSession();
} catch (e) {
// Show a SnackBar for any error during the NFC write process.
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Error emitting NFC data: $e')));
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(content: Text('Error emitting NFC data: $e')));
NfcManager.instance
.stopSession(errorMessage: 'Error emitting NFC data');
}
Expand Down
43 changes: 25 additions & 18 deletions lib/flutter_flow/custom_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,33 @@ String promptGenerator(
""";
}

dynamic stringToJson(String response) {
dynamic stringToJson(dynamic response) {
try {
// Decode the JSON response
final decodedResponse = jsonDecode(response);

// Extract questions and answers from the API response
if (decodedResponse is Map<String, dynamic> &&
decodedResponse.containsKey('choices') &&
decodedResponse['choices'] is List) {
final content = decodedResponse['choices'][0]['message']['content'];
final extractedJson = jsonDecode(content);

if (extractedJson is Map<String, dynamic> &&
extractedJson.containsKey('questions')) {
return extractedJson; // Return the extracted questions JSON
}
}
// Ensure the input is converted to a string if not already
final String responseString =
response is String ? response : jsonEncode(response);

// Parse the input response as a JSON object
final Map<String, dynamic> jsonResponse = jsonDecode(responseString);

// Navigate to the "content" field inside the response
final String content = jsonResponse['choices'][0]['message']['content'];

// Remove escape characters and clean up the string
final String cleanedContent = content
.replaceAll('\\n', '\n') // Replace escaped newlines
.replaceAll('\\"', '"') // Replace escaped double quotes
.replaceAll('\\\\', '\\') // Replace escaped backslashes
.trim();

// Parse the cleaned string into a proper JSON object
final dynamic parsedJson = jsonDecode(cleanedContent);

// Return the parsed JSON object
return parsedJson;
} catch (e) {
// Handle errors and return empty JSON object
return {};
// Return an error message if parsing fails
return {'error': 'Failed to parse JSON', 'details': e.toString()};
}
}

Expand Down
107 changes: 62 additions & 45 deletions lib/flutter_flow/flutter_flow_drop_down.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:dropdown_button2/dropdown_button2.dart';

import 'package:webviewx_plus/webviewx_plus.dart';
import 'package:flutter/foundation.dart';
import 'form_field_controller.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -214,10 +214,17 @@ class _FlutterFlowDropDownState<T> extends State<FlutterFlowDropDown<T>> {
.map(
(option) => DropdownMenuItem<T>(
value: option,
child: Padding(
padding: _useDropdown2() ? horizontalMargin : EdgeInsets.zero,
child: Text(optionLabels[option] ?? '', style: widget.textStyle),
)),
child: Builder(builder: (_) {
final child = Padding(
padding: _useDropdown2() ? horizontalMargin : EdgeInsets.zero,
child:
Text(optionLabels[option] ?? '', style: widget.textStyle),
);
if (kIsWeb) {
return WebViewAware(child: child);
}
return child;
})),
)
.toList();

Expand All @@ -231,37 +238,41 @@ class _FlutterFlowDropDownState<T> extends State<FlutterFlowDropDown<T>> {
builder: (context, menuSetState) {
final isSelected =
multiSelectController.value?.contains(item) ?? false;
return InkWell(
onTap: () {
multiSelectController.value ??= [];
isSelected
? multiSelectController.value!.remove(item)
: multiSelectController.value!.add(item);
multiSelectController.update();
// This rebuilds the StatefulWidget to update the button's text.
setState(() {});
// This rebuilds the dropdownMenu Widget to update the check mark.
menuSetState(() {});
},
child: Container(
height: double.infinity,
padding: horizontalMargin,
child: Row(
children: [
if (isSelected)
const Icon(Icons.check_box_outlined)
else
const Icon(Icons.check_box_outline_blank),
const SizedBox(width: 16),
Expanded(
child: Text(
optionLabels[item]!,
style: widget.textStyle,
),
return InkWell(onTap: () {
multiSelectController.value ??= [];
isSelected
? multiSelectController.value!.remove(item)
: multiSelectController.value!.add(item);
multiSelectController.update();
// This rebuilds the StatefulWidget to update the button's text.
setState(() {});
// This rebuilds the dropdownMenu Widget to update the check mark.
menuSetState(() {});
}, child: Builder(builder: (_) {
final child = Container(
height: double.infinity,
padding: horizontalMargin,
child: Row(
children: [
if (isSelected)
const Icon(Icons.check_box_outlined)
else
const Icon(Icons.check_box_outline_blank),
const SizedBox(width: 16),
Expanded(
child: Text(
optionLabels[item]!,
style: widget.textStyle,
),
],
),
));
),
],
),
);
if (kIsWeb) {
return WebViewAware(child: child);
}
return child;
}));
},
),
),
Expand Down Expand Up @@ -307,16 +318,22 @@ class _FlutterFlowDropDownState<T> extends State<FlutterFlowDropDown<T>> {
.map(
(item) => Align(
alignment: AlignmentDirectional.centerStart,
child: Text(
isMultiSelect
? currentValues
.where((v) => optionLabels.containsKey(v))
.map((v) => optionLabels[v])
.join(', ')
: optionLabels[item]!,
style: widget.textStyle,
maxLines: 1,
)),
child: Builder(builder: (_) {
final child = Text(
isMultiSelect
? currentValues
.where((v) => optionLabels.containsKey(v))
.map((v) => optionLabels[v])
.join(', ')
: optionLabels[item]!,
style: widget.textStyle,
maxLines: 1,
);
if (kIsWeb) {
return WebViewAware(child: child);
}
return child;
})),
)
.toList(),
dropdownSearchData: widget.isSearchable
Expand Down
Loading

0 comments on commit 13937d3

Please sign in to comment.