()
| 1161 | } |
| 1162 | |
| 1163 | func layoutServiceAddress() fyne.CanvasObject { |
| 1164 | session.Domain = "app.service" |
| 1165 | |
| 1166 | wSpacer := widget.NewLabel(" ") |
| 1167 | frame := &iframe{} |
| 1168 | |
| 1169 | btnCreate := widget.NewButton("Create", nil) |
| 1170 | |
| 1171 | wPaymentID := widget.NewEntry() |
| 1172 | |
| 1173 | wReceiver := widget.NewEntry() |
| 1174 | wReceiver.Text = engram.Disk.GetAddress().String() |
| 1175 | wReceiver.Disable() |
| 1176 | |
| 1177 | tx.Address, _ = globals.ParseValidateAddress(engram.Disk.GetAddress().String()) |
| 1178 | |
| 1179 | wReceiver.SetPlaceHolder("Receiver username or address") |
| 1180 | wReceiver.SetValidationError(nil) |
| 1181 | |
| 1182 | wAmount := widget.NewEntry() |
| 1183 | wAmount.SetPlaceHolder("Amount") |
| 1184 | |
| 1185 | wMessage := widget.NewEntry() |
| 1186 | wMessage.SetPlaceHolder("Message") |
| 1187 | wMessage.Validator = func(s string) (err error) { |
| 1188 | bytes := []byte(s) |
| 1189 | if len(bytes) <= 130 { |
| 1190 | tx.Comment = s |
| 1191 | } else { |
| 1192 | err = errors.New("message too long") |
| 1193 | wMessage.SetValidationError(err) |
| 1194 | } |
| 1195 | |
| 1196 | return |
| 1197 | } |
| 1198 | |
| 1199 | wAmount.Validator = func(s string) error { |
| 1200 | if s == "" { |
| 1201 | tx.Amount = 0 |
| 1202 | wAmount.SetValidationError(errors.New("invalid transaction amount")) |
| 1203 | btnCreate.Disable() |
| 1204 | } else { |
| 1205 | amount, err := globals.ParseAmount(s) |
| 1206 | if err != nil { |
| 1207 | tx.Amount = 0 |
| 1208 | wAmount.SetValidationError(errors.New("invalid transaction amount")) |
| 1209 | btnCreate.Disable() |
| 1210 | return errors.New("invalid transaction amount") |
| 1211 | } |
| 1212 | wAmount.SetValidationError(nil) |
| 1213 | tx.Amount = amount |
| 1214 | btnCreate.Enable() |
| 1215 | |
| 1216 | return nil |
| 1217 | } |
| 1218 | return errors.New("invalid transaction amount") |
| 1219 | } |
| 1220 |
no test coverage detected