Skip to content

Commit

Permalink
feat: Add logo based on theme for enterprise profile #2847
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Aug 23, 2024
1 parent d892df5 commit 722cc26
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/app/shared/widget/button/my_elevated_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MyElevatedButton extends StatelessWidget {
onPressed: onPressed,
),
onPressed: onPressed,
child: Text(
child: MyText(
text.toUpperCase(),
style: Theme.of(context).textTheme.titleLarge!.copyWith(
fontWeight: FontWeight.bold,
Expand Down
11 changes: 10 additions & 1 deletion lib/app/shared/widget/wallet_logo.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/flavor/flavor.dart';
import 'package:altme/theme/theme_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

Expand Down Expand Up @@ -35,11 +36,19 @@ class WalletLogo extends StatelessWidget {
case ProfileType.ebsiV3:
image = ImageStrings.ebsiLogo;
case ProfileType.enterprise:
image = profileModel.profileSetting.generalOptions.companyLogo;
final isLightTheme =
Theme.of(context).brightness == Brightness.light;

final generalOptions = profileModel.profileSetting.generalOptions;
image = isLightTheme
? generalOptions.companyLogoLight
: generalOptions.companyLogo;

case ProfileType.diipv2point1:
case ProfileType.diipv3:
image = ImageStrings.diipLogo;
}

return Column(
children: [
Center(
Expand Down
22 changes: 20 additions & 2 deletions lib/dashboard/profile/cubit/profile_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,28 @@ class ProfileCubit extends Cubit<ProfileState> {
}
}

String? companyLogoLight = profileSetting.generalOptions.companyLogoLight;

///company Logo Light
if (isURL(companyLogoLight)) {
try {
final http.Response response =
await http.get(Uri.parse(companyLogoLight));
if (response.statusCode == 200) {
companyLogoLight = base64Encode(response.bodyBytes);
}
} catch (e) {
//
}
}

final profileModel = state.model.copyWith(
profileSetting: profileSetting.copyWith(
generalOptions:
profileSetting.generalOptions.copyWith(companyLogo: companyLogo),
generalOptions: profileSetting.generalOptions.copyWith(
companyLogo: companyLogo,
companyLogoLight: companyLogoLight,
),
discoverCardsOptions: profileSetting.discoverCardsOptions?.copyWith(
displayExternalIssuer: updatedExternalIssuer,
),
Expand Down
5 changes: 5 additions & 0 deletions lib/dashboard/profile/models/profile_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ class GeneralOptions extends Equatable {
required this.companyName,
required this.companyWebsite,
required this.companyLogo,
required this.companyLogoLight,
required this.tagLine,
this.splashScreenTitle,
required this.profileName,
Expand All @@ -366,6 +367,7 @@ class GeneralOptions extends Equatable {
companyName: '',
companyWebsite: '',
companyLogo: '',
companyLogoLight: '',
tagLine: '',
splashScreenTitle: '',
profileName: '',
Expand All @@ -380,6 +382,7 @@ class GeneralOptions extends Equatable {
final String companyName;
final String companyWebsite;
final String companyLogo;
final String companyLogoLight;
final String tagLine;
final String? splashScreenTitle;
final String profileName;
Expand All @@ -396,6 +399,7 @@ class GeneralOptions extends Equatable {
String? companyName,
String? companyWebsite,
String? companyLogo,
String? companyLogoLight,
String? splashScreenTitle,
String? tagLine,
String? profileName,
Expand All @@ -410,6 +414,7 @@ class GeneralOptions extends Equatable {
companyName: companyName ?? this.companyName,
companyWebsite: companyWebsite ?? this.companyWebsite,
companyLogo: companyLogo ?? this.companyLogo,
companyLogoLight: companyLogoLight ?? this.companyLogoLight,
tagLine: tagLine ?? this.tagLine,
splashScreenTitle: splashScreenTitle ?? this.splashScreenTitle,
profileName: profileName ?? this.profileName,
Expand Down
1 change: 1 addition & 0 deletions test/app/shared/widget/wallet_logo_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ void main() {
companyName: '',
companyWebsite: '',
companyLogo: 'https://www.demo.com',
companyLogoLight: 'https://www.demo.com',
tagLine: '',
splashScreenTitle: '',
profileName: '',
Expand Down

0 comments on commit 722cc26

Please sign in to comment.