Skip to content

Commit

Permalink
clear update app data on pop
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmohsin7 committed Nov 16, 2024
1 parent 9df4b1d commit da5a273
Showing 1 changed file with 128 additions and 123 deletions.
251 changes: 128 additions & 123 deletions app/lib/pages/apps/update_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,151 +36,156 @@ class _UpdateAppPageState extends State<UpdateAppPage> {
title: const Text('Update Your App'),
backgroundColor: Theme.of(context).colorScheme.primary,
),
body: Consumer<AddAppProvider>(builder: (context, provider, child) {
if (provider.isUpdating) {
return const Center(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
SizedBox(
height: 14,
),
Text(
'Updating your app',
style: TextStyle(color: Colors.white),
),
],
),
);
}
if (provider.isLoading) {
return const Center(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
SizedBox(
height: 14,
),
Text(
'Fetching your app details',
style: TextStyle(color: Colors.white),
),
],
),
);
}
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: provider.formKey,
body: PopScope(
onPopInvoked: (didPop) {
context.read<AddAppProvider>().clear();
},
child: Consumer<AddAppProvider>(builder: (context, provider, child) {
if (provider.isUpdating) {
return const Center(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 12,
CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
const Text(
'App Capabilities',
style: TextStyle(color: Colors.white, fontSize: 16),
SizedBox(
height: 14,
),
const SizedBox(height: 60, child: CapabilitiesChipsWidget()),
const SizedBox(
height: 18,
Text(
'Updating your app',
style: TextStyle(color: Colors.white),
),
],
),
);
}
if (provider.isLoading) {
return const Center(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
AppMetadataWidget(
pickImage: () async {
await provider.updateImage();
},
imageFile: provider.imageFile,
appNameController: provider.appNameController,
appDescriptionController: provider.appDescriptionController,
creatorNameController: provider.creatorNameController,
creatorEmailController: provider.creatorEmailController,
categories: provider.categories,
setAppCategory: provider.setAppCategory,
imageUrl: provider.imageUrl,
category: provider.appCategory,
SizedBox(
height: 14,
),
const SizedBox(
height: 30,
Text(
'Fetching your app details',
style: TextStyle(color: Colors.white),
),
if (provider.capabilitySelected())
],
),
);
}
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: provider.formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 12,
),
const Text(
'App Specific Details',
'App Capabilities',
style: TextStyle(color: Colors.white, fontSize: 16),
),
if (provider.isCapabilitySelectedById('chat'))
const SizedBox(height: 60, child: CapabilitiesChipsWidget()),
const SizedBox(
height: 20,
height: 18,
),
if (provider.isCapabilitySelectedById('chat'))
PromptTextField(
controller: provider.chatPromptController,
label: 'Chat Prompt',
icon: Icons.chat,
AppMetadataWidget(
pickImage: () async {
await provider.updateImage();
},
imageFile: provider.imageFile,
appNameController: provider.appNameController,
appDescriptionController: provider.appDescriptionController,
creatorNameController: provider.creatorNameController,
creatorEmailController: provider.creatorEmailController,
categories: provider.categories,
setAppCategory: provider.setAppCategory,
imageUrl: provider.imageUrl,
category: provider.appCategory,
),
if (provider.isCapabilitySelectedById('memories'))
const SizedBox(
height: 24,
height: 30,
),
if (provider.capabilitySelected())
const Text(
'App Specific Details',
style: TextStyle(color: Colors.white, fontSize: 16),
),
if (provider.isCapabilitySelectedById('chat'))
const SizedBox(
height: 20,
),
if (provider.isCapabilitySelectedById('chat'))
PromptTextField(
controller: provider.chatPromptController,
label: 'Chat Prompt',
icon: Icons.chat,
),
if (provider.isCapabilitySelectedById('memories'))
const SizedBox(
height: 24,
),
if (provider.isCapabilitySelectedById('memories'))
PromptTextField(
controller: provider.memoryPromptController,
label: 'Memory Prompt',
icon: Icons.memory,
),
const ExternalTriggerFieldsWidget(),
if (provider.capabilitySelected())
const SizedBox(
height: 30,
),
const NotificationScopesChipsWidget(),
const SizedBox(
height: 30,
),
if (provider.isCapabilitySelectedById('memories'))
PromptTextField(
controller: provider.memoryPromptController,
label: 'Memory Prompt',
icon: Icons.memory,
GradientButton(
title: 'Update App',
onPressed: () {
var isValid = provider.validateForm();
if (isValid) {
showDialog(
context: context,
builder: (c) => getDialog(
context,
() => Navigator.pop(context),
() async {
Navigator.pop(context);
await provider.updateApp();
},
'Update App?',
'Are you sure you want to update your app? The changes will reflect once reviewed by our team.',
okButtonText: 'Confirm',
),
);
}
},
),
const ExternalTriggerFieldsWidget(),
if (provider.capabilitySelected())
const SizedBox(
height: 30,
),
const NotificationScopesChipsWidget(),
const SizedBox(
height: 30,
),
GradientButton(
title: 'Update App',
onPressed: () {
var isValid = provider.validateForm();
if (isValid) {
showDialog(
context: context,
builder: (c) => getDialog(
context,
() => Navigator.pop(context),
() async {
Navigator.pop(context);
await provider.updateApp();
},
'Update App?',
'Are you sure you want to update your app? The changes will reflect once reviewed by our team.',
okButtonText: 'Confirm',
),
);
}
},
),
const SizedBox(
height: 30,
),
],
],
),
),
),
),
);
}),
);
}),
),
);
}
}

0 comments on commit da5a273

Please sign in to comment.