Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theming whitelabel.py script #214

Merged
merged 36 commits into from
Jan 2, 2024

Conversation

rnr
Copy link
Contributor

@rnr rnr commented Dec 19, 2023

Added the theming whitelabel.py script

This script can override Assets (images, colors, app Icon) and change project settings (app bundle ID and development team ID). Please follow this documentation to install Python dependencies if needed and to read how to work/configure.

Changes

1) Allocated colors for more flexibility:

  • loginNavigationText
  • loginBackground
  • accentButtonColor
  • SplashBackground

2) Added ThemeConfig for feature flags related to Theming

3) Changed textInputShape and buttonShape to support rounded and rectangle corners.

Custom edX theme example

  1. Clone https://github.com/edx/edx-mobile-config into the OpenEdX root folder and switch to the anton/openedX-theming branch.

  2. From the OpenEdX root folder, run the script as:

python config_script/whitelabel.py --config-file=edx-mobile-config/openEdXAssets/whitelabel.yaml -v
  1. Install on your simulator or device

All possible config parameters are described in this documentation

rnr added 30 commits December 1, 2023 11:02
@miankhalid
Copy link

@shafqat-muneer will be reviewing this PR from Axinite's side.

@shafqat-muneer
Copy link
Contributor

PR review is in progress from my side.

@rnr rnr removed the request for review from saeedbashir December 26, 2023 10:33
@shafqat-muneer
Copy link
Contributor

After running this command on terminal:

python3 config_script/whitelabel.py --config-file=path/to/configfile/whitelabel.yaml -v

Got this error:

File "/path/to/config_script/whitelabel.py", line 6, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

Resolved the issue by installing pyyaml by following command:

pip3 install pyyaml

Suggestion: I think we should document every dependency in Theming_implementation.md file so that it can easily be configured on new system independently.

@shafqat-muneer
Copy link
Contributor

We utilize distinct bundle identifiers for our Development (Dev), Staging (Stage), and Production (Prod) environments. Is it possible to modify the bundle identifiers for all environments simultaneously, or do we need to execute the script multiple times to update each environment's bundle identifier individually?

Comment on lines 5 to 7
The `whitelabel.py` theming script requires the following Python dependencies to be installed:
- `pip install coloredlogs`
- `pip install pillow`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to execute the following command for installing dependencies. I believe it would be beneficial to include these statements as well.

  • pip3 install coloredlogs
  • pip3 install pillow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added to documentation all dependencies which are not default python's libs

- `pip install pillow`

## How to Run the Script
The theming script `whitelabel.py` can be ran from the OpenEdX iOS root project folder with the following command:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: can be ran to can be run

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Documentation/Theming_implementation.md Show resolved Hide resolved
EXAMPLE_CONFIG_FILE = """
---
# Notes:
# Config file can contain next optins:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: optins to options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@shafqat-muneer
Copy link
Contributor

Review is in progress.

@shafqat-muneer
Copy link
Contributor

@rnr Getting SyntaxWarning after running command:

python3 config_script/whitelabel.py --config-file=/path/to/whitelabel.yaml

Error Details:

/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\s'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"

@rnr
Copy link
Contributor Author

rnr commented Dec 27, 2023

@rnr Getting SyntaxWarning after running command:

python3 config_script/whitelabel.py --config-file=/path/to/whitelabel.yaml

Error Details:

/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\s'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"

@shafqat-muneer Could you show what is content of whitelabel.yaml file for this error please

@shafqat-muneer
Copy link
Contributor

@rnr Getting SyntaxWarning after running command:

python3 config_script/whitelabel.py --config-file=/path/to/whitelabel.yaml

Error Details:

/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\s'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"

@shafqat-muneer Could you show what is content of whitelabel.yaml file for this error please

@rnr I tried it with just import_dir content. whitelabel.yaml looks like this:

import_dir: '/Users/shafqatmuneer/msmq/Projects/2U/_Daily/20231226/Images' # folder where importing images are placed

I also checked with same sample file content in config repo, it's also giving error. With whitelabel.yaml file in config repo, error is this:

/Users/shafqatmuneer/msmq/Projects/2U/CodeBase/openedx-app-ios/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/Users/shafqatmuneer/msmq/Projects/2U/CodeBase/openedx-app-ios/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/Users/shafqatmuneer/msmq/Projects/2U/CodeBase/openedx-app-ios/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\s'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"

@rnr
Copy link
Contributor Author

rnr commented Dec 27, 2023

@rnr Getting SyntaxWarning after running command:

python3 config_script/whitelabel.py --config-file=/path/to/whitelabel.yaml

Error Details:

/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/path/to/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\s'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"

@shafqat-muneer Could you show what is content of whitelabel.yaml file for this error please

@rnr I tried it with just import_dir content. whitelabel.yaml looks like this:

import_dir: '/Users/shafqatmuneer/msmq/Projects/2U/_Daily/20231226/Images' # folder where importing images are placed

I also checked with same sample file content in config repo, it's also giving error. With whitelabel.yaml file in config repo, error is this:

/Users/shafqatmuneer/msmq/Projects/2U/CodeBase/openedx-app-ios/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/Users/shafqatmuneer/msmq/Projects/2U/CodeBase/openedx-app-ios/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\*'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"
/Users/shafqatmuneer/msmq/Projects/2U/CodeBase/openedx-app-ios/config_script/whitelabel.py:317: SyntaxWarning: invalid escape sequence '\s'
  return f"/\* {build_config} \*/ = {{\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = [\s|\S]*\t\t\tname = {build_config};"

@shafqat-muneer added extra escaping to regex inside python script. should be fine now. please check

@rnr rnr requested a review from shafqat-muneer December 27, 2023 14:07
Copy link
Contributor

@shafqat-muneer shafqat-muneer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

  • Script is working
  • Documentation related improvements are done
  • Dependencies are listed
  • Sample whitelabel.yaml file added
Screenshot 2023-12-27 at 9 08 04 PM

@volodymyr-chekyrta
Copy link
Contributor

Hello everyone!

I was wondering if we are waiting for @eyatsenkoperpetio review before merging this PR, or if we can go ahead and merge it now?

@rnr
Copy link
Contributor Author

rnr commented Jan 2, 2024

Hello everyone!

I was wondering if we are waiting for @eyatsenkoperpetio review before merging this PR, or if we can go ahead and merge it now?

Hello @volodymyr-chekyrta
I think we are ready to merge since @eyatsenkoperpetio just approved
Thank you

@volodymyr-chekyrta volodymyr-chekyrta merged commit 1bc4a75 into openedx:develop Jan 2, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] iOS build script for Custom Application Configuration
5 participants