Browse Source

basic support titleBarTextColor

Daniel Zlotin 7 years ago
parent
commit
77ed6ad2a5

+ 27
- 0
e2e/ScreenStyle.test.js View File

1
+const Utils = require('./Utils');
2
+const elementByLabel = Utils.elementByLabel;
3
+
4
+describe('screen style', () => {
5
+  beforeEach(async () => {
6
+    await device.relaunchApp();
7
+  });
8
+
9
+  it('declare a navigationOptions on container component', async () => {
10
+    await elementByLabel('Push Options Screen').tap();
11
+    await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
12
+  });
13
+
14
+  it('change title on container component', async () => {
15
+    await elementByLabel('Push Options Screen').tap();
16
+    await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
17
+    await elementByLabel('Dynamic Options').tap();
18
+    await expect(element(by.label('Dynamic Title').and(by.type('UILabel')))).toBeVisible();
19
+  });
20
+
21
+  it('set dynamic options with valid options will do something and not crash', async () => {
22
+    // we have no way of testing individual styles for the screen
23
+    await elementByLabel('Push Options Screen').tap();
24
+    await elementByLabel('Dynamic Options').tap();
25
+    await expect(element(by.label('Options Screen'))).toBeVisible();
26
+  });
27
+});

+ 0
- 15
e2e/ScreenStyleDynamic.test.js View File

1
-const Utils = require('./Utils');
2
-const elementByLabel = Utils.elementByLabel;
3
-
4
-describe('screen style - dynamic', () => {
5
-  beforeEach(async () => {
6
-    await device.relaunchApp();
7
-  });
8
-
9
-  it('change title on container component', async () => {
10
-    await elementByLabel('Push Options Screen').tap();
11
-    await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
12
-    await elementByLabel('Dynamic Options').tap();
13
-    await expect(element(by.label('Dynamic Title').and(by.type('UILabel')))).toBeVisible();
14
-  });
15
-});

+ 0
- 13
e2e/ScreenStyleStatic.test.js View File

1
-const Utils = require('./Utils');
2
-const elementByLabel = Utils.elementByLabel;
3
-
4
-describe('screen style - static', () => {
5
-  beforeEach(async () => {
6
-    await device.relaunchApp();
7
-  });
8
-
9
-  it('declare a navigationOptions on container component', async () => {
10
-    await elementByLabel('Push Options Screen').tap();
11
-    await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
12
-  });
13
-});

+ 14
- 1
lib/ios/RNNCommandsHandler.m View File

35
 
35
 
36
 -(void) setOptions:(NSString*)containerId options:(NSDictionary*)options {
36
 -(void) setOptions:(NSString*)containerId options:(NSDictionary*)options {
37
 	[self assertReady];
37
 	[self assertReady];
38
-	[[_store findContainerForId:containerId] setTitle:options[@"title"]];
38
+	UIViewController* vc = [_store findContainerForId:containerId];
39
+	
40
+	NSString* title = options[@"title"];
41
+	NSString* topBarTextColor = options[@"topBarTextColor"];
42
+	
43
+	[vc setTitle:title];
44
+	
45
+	int rgb = [[topBarTextColor substringFromIndex:1] intValue];
46
+	UIColor* color = [UIColor colorWithRed:((float)((rgb & 0xFF0000) >> 16))/255.0 \
47
+									 green:((float)((rgb & 0x00FF00) >>  8))/255.0 \
48
+									  blue:((float)((rgb & 0x0000FF) >>  0))/255.0 \
49
+									 alpha:1.0];
50
+	vc.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: color};
51
+	
39
 }
52
 }
40
 
53
 
41
 -(void) push:(NSString*)containerId layout:(NSDictionary*)layout {
54
 -(void) push:(NSString*)containerId layout:(NSDictionary*)layout {

+ 2
- 1
playground/src/containers/OptionsScreen.js View File

31
 
31
 
32
   onClickDynamicOptions() {
32
   onClickDynamicOptions() {
33
     Navigation.setOptions(this.props.containerId, {
33
     Navigation.setOptions(this.props.containerId, {
34
-      title: 'Dynamic Title'
34
+      title: 'Dynamic Title',
35
+      topBarTextColor: '#123456'
35
     });
36
     });
36
   }
37
   }
37
 }
38
 }