1
1
import { StyleSheet , Button , TextInput } from "react-native" ;
2
2
import { Text , View } from "@/components/Themed" ;
3
- import { useState } from "react" ;
3
+ import { useEffect , useState } from "react" ;
4
4
import { responseTestService } from "@/services/ResponseTest.service" ;
5
5
import { downloadTestService } from "@/services/DownloadTest.service" ;
6
6
import { TableHeader } from "@/components/Table/TableHeader" ;
@@ -9,7 +9,8 @@ import { useTableData } from "../hooks/useTableData";
9
9
import { useTestIpCount } from "../hooks/useTestIpCount" ;
10
10
import { TableRows } from "@/components/Table/TableRows" ;
11
11
import { initialTestPageTableHeaderCols , MyTableHeaderColumn } from "../model" ;
12
- import { RequestStatus } from "@/typings" ;
12
+ import { useTestRunningStatus } from "../hooks/useTestRunningStatus" ;
13
+ import { miniStyle } from "@/theme" ;
13
14
14
15
export default function TestPage ( { path } : { path : string } ) {
15
16
const { testIpCount, setTestIpCount, getIpList } = useTestIpCount ( ) ;
@@ -37,13 +38,32 @@ export default function TestPage({ path }: { path: string }) {
37
38
changeTableHeadersSortType,
38
39
} = useTableHeader < MyTableHeaderColumn > ( initialTestPageTableHeaderCols ) ;
39
40
41
+ const { testRunningStatus, nextTestRunningStatus } = useTestRunningStatus ( ) ;
42
+
40
43
function onReset ( ) {
41
44
responseTestService . stop ( ) ;
42
45
downloadTestService . stop ( ) ;
43
46
resetTableData ( ) ;
44
47
resetTableHeader ( ) ;
45
- initTableData ( getIpList ( ) ) ;
48
+ const newIpList = getIpList ( ) ;
49
+ initTableData ( newIpList ) ;
50
+ nextTestRunningStatus ( ) ;
46
51
}
52
+
53
+ useEffect ( ( ) => {
54
+ // in the future may need to add a status check
55
+ startResponseSpeedTest (
56
+ getSelectedIpList ( ) ,
57
+ Number ( testIpCoCurrentCount ) ,
58
+ testUrl
59
+ ) ;
60
+ startDownloadSpeedTest (
61
+ getSelectedIpList ( ) ,
62
+ Number ( testIpCoCurrentCount ) ,
63
+ testUrl
64
+ ) ;
65
+ } , [ testRunningStatus ] ) ;
66
+
47
67
function onSort (
48
68
colId : MyTableHeaderColumn [ "id" ] ,
49
69
sortType : MyTableHeaderColumn [ "sort" ]
@@ -70,7 +90,7 @@ export default function TestPage({ path }: { path: string }) {
70
90
}
71
91
title = "TEST RESPOND "
72
92
/>
73
- < View style = { { marginRight : 10 } } > </ View >
93
+ < View style = { { marginRight : 5 } } > </ View >
74
94
< Button
75
95
onPress = { ( ) =>
76
96
startDownloadSpeedTest (
@@ -81,7 +101,7 @@ export default function TestPage({ path }: { path: string }) {
81
101
}
82
102
title = "TEST DOWNLOAD"
83
103
/>
84
- < View style = { { marginRight : 10 } } > </ View >
104
+ < View style = { { marginRight : 5 } } > </ View >
85
105
< Button onPress = { onReset } title = "START" />
86
106
</ View >
87
107
< View style = { styles . toolbar } >
@@ -109,8 +129,18 @@ export default function TestPage({ path }: { path: string }) {
109
129
/>
110
130
</ View >
111
131
112
- < TableHeader onSort = { onSort } cols = { tableHeaders } />
113
- < TableRows rows = { tableData } columns = { tableHeaders } rowKeyName = { "ip" } />
132
+ < TableHeader
133
+ onSort = { onSort }
134
+ cols = { tableHeaders }
135
+ style = { { cellTextStyle : miniStyle . textStyle } }
136
+ />
137
+
138
+ < TableRows
139
+ rows = { tableData }
140
+ columns = { tableHeaders }
141
+ rowKeyName = { "ip" }
142
+ style = { { cellTextStyle : miniStyle . textStyle } }
143
+ />
114
144
</ View >
115
145
) ;
116
146
}
0 commit comments