소스 검색

basic support titleBarTextColor

Daniel Zlotin 7 년 전
부모
커밋
77ed6ad2a5
5개의 변경된 파일43개의 추가작업 그리고 30개의 파일을 삭제
  1. 27
    0
      e2e/ScreenStyle.test.js
  2. 0
    15
      e2e/ScreenStyleDynamic.test.js
  3. 0
    13
      e2e/ScreenStyleStatic.test.js
  4. 14
    1
      lib/ios/RNNCommandsHandler.m
  5. 2
    1
      playground/src/containers/OptionsScreen.js

+ 27
- 0
e2e/ScreenStyle.test.js 파일 보기

@@ -0,0 +1,27 @@
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 파일 보기

@@ -1,15 +0,0 @@
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 파일 보기

@@ -1,13 +0,0 @@
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 파일 보기

@@ -35,7 +35,20 @@
35 35
 
36 36
 -(void) setOptions:(NSString*)containerId options:(NSDictionary*)options {
37 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 54
 -(void) push:(NSString*)containerId layout:(NSDictionary*)layout {

+ 2
- 1
playground/src/containers/OptionsScreen.js 파일 보기

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